[讨论]这样写对不对呢!?
//文件名为Employee.javapublic class Employee
{
private String name;
private double salary;
private int dep_number;
public Employee (String n,double s)
{
name=n;
salary=s;
}
public void set_dep(int dep_num)
{
dep_number=dep_num;
}
public int show__depNo()
{
return dep_number;
}
public void setSalary(double s)
{
salary=s;
}
public void raiseSalary(double by_percent)
{
salary=salary*(1+by_percent);
}
public double getSalary()
{
return salary;
}
}
class Manager extends Employee
{
private String secretaryName;
private int dep_num;
public Manager(String n,double s,int dep_num)
{
super (n,s);
this.dep_num=dep_num;
}
public void setSecretary(String name)
{
secretaryName=name;
}
public String getSecretaryName()
{
return secretaryName;
}
}
class ManagerTest
{
public static void main(String args[])
{
Manager manager_1=new Manager("Annie",41000,2);
manager_1.setSecretaryName("Mariee");
manager_1.raiseSalary(0.01);
System.out.println("The manager's salary is "+manager_1.getSalary());
}
}
class ManagerWithOverWriTest
{
public static void main(String args[])
{
ManagerWithOverWri manager_1=new ManagerWithOverWri("Annie",4100,2);
manager_1.setSecretary("Mariee");
manager_1.raiseSalary(0.01);
System.out.println("The manager's salary is "+manager_1.getSalary());
}
}
要求输出结果为:
call raiseSalary method in Manager
The manager's secretary is Mariee
The manager's salary is 43460.0
不知道会不会又是书上的错误!?
麻烦大家帮我看一下啦!