- public class Test1 {
- public static void main(String[] args) {
- Employee em = new Employee("lisi", "9527", 3000);
- Manager ma = new Manager("wangwu", "3978", 5500, 1500);
- System.out.println("员工:"+em.getName()+"工号:"+em.getNumber()+"工资:"+em.getSalary());
- System.out.println("员工:"+ma.getName()+"工号:"+ma.getNumber()+"工资:"+em.getSalary());
- }
- }
- class Employee {//职工
- private String name;
- private String number;
- private double Salary;
- public void setName(String name) {
- this.name = name;
- }
- public void setNumber(String number) {
- this.number = number;
- }
- public void setSalary(double Salary) {
- this.Salary = Salary;
- }
- public String getName() {
- return name;
- }
- public String getNumber() {
- return number;
- }
- public double getSalary() {
- return Salary;
- }
- public Employee(String name,String number,double Salary){
- this.name=name;
- this.number=number;
- this.Salary=Salary;
- }
- }
- class Manager extends Employee{//经理继承
- private double award;//奖金
- public double getAward() {
- return award;
- }
- public void setAward(double award) {
- this.award = award;
- }
- public Manager(String name, String number, double Salary,double award) {
- super(name, number, Salary);
- // TODO Auto-generated constructor stub
- this.award=award;
- }
- public double getSalary(){
- return super.getSalary()+this.award;
- }
- }
复制代码
员工:lisi工号: 9527工资:3000.0
经理:wangwu工号: 3978工资:3000.0
经理的工资为什么数值不对啊 到底哪里错了
|