السلام عليكم
لدي تساؤل بسيط وعلى فرض انه لدي صنفين احدهما يرث من الثاني
public class Employee {
protected static int id;
protected static String name;
protected static String address;
protected static double salary;
public Employee(int id, String name, String address, double salary) {
this.id = id;
this.name = name;
this.address = address;
this.salary = salary;
}
//sette and getterpublic class Manger extends Employee{
public Manger(int id, String name, String address, double salary) {
super(id, name, address, salary);
}
public static void manging(){
// some varibles
Employee employee = new Employee (id, address, address, salary);
// some operations using Object employee
}السؤال هو انه لدى محاولتي عمل كائن employee يحوي الخائص الرقم والاسم والعنوان والراتب كلن هذا غير ممكن الا اذا قمت بتعريف المتغيرات في الصنف Employee بوصفها ساكنة Static
protected static int id; protected static String name; protected static String address; protected static double salary;
سوى ذلك فساحصل على خطا دائما
فما الحل الافضل ام ان هذا هو الحل الوحيد؟