Public class ManagerTest
{
Public static void main (String [] args)
{
Manager boss=new Manager (" Carl Cracker ", 80000198, 7,12,15);
Boss. SetBonus (5000);
Boss. The getSalary ();
The Employee staff []=new Employee [3].
The staff [0]=boss;
The staff [1]=new Employee (" Harry Hacker ", 50000198, 9,10,1);
The staff [2]=new Employee (" Tommy Tester ", 40000199 0,3,15);
For (the Employee e: staff)
System. The out. Println (" name="+ um participant etName () +", Salary="+ um participant etSalary ());
}
}
The class Employee
{
Public Employee (String n, double s, int year, int expressions using, int day
{
Name=n;
Salary=s;
GregorianCalendar calendar=new GregorianCalendar (year, expressions using 1, day);
HireDay=calendar. GetTime ();
}
Public String getName ()
{
return name;
}
Public double getSalary ()
{
Return the salary;
}
Public Date getHireDay ()
{
Return hireDay;
}
Public void raiseSalary (double byPercent)
{
Double raise=salary * byPercent/100;
Salary +=raise;
}
private String name;
private double salary;
Private Date hireDay;
}
The class Manager extends the Employee
{
Public Manager (String n, double s, int year, int the month, int day
{
Super (n, s, year, month, day);
Bonus=0;
}
Public double gerSalary ()
{
System. The out. Println (" * * * * * * * * * * * ");
Double baseSalary=super. GetSalary ();
Return baseSalary + bonus;
}
Public void setBonus (double) b
{
Bonus=b;
}
Private double bonus;
}
CodePudding user response:
Well, rewrite the grammar I believe that you already know, you is a subclass of gerSalary (), the parent class is getSalary (); Spelling errors, natural not rewrittenCodePudding user response:
LS vision is goodCodePudding user response:
Recently in the static block, every brother please answer, is that the static block in the subclass, whether can only call a static method of the parent, I tried it on found unable to call the parent class of ordinary method,CodePudding user response: