作者在 2016-03-02 12:50:08 发布以下内容
import java.util.Date;
class Employee
{
private String name;
private double salary;
private Date birthday;
public Employee()
{
}
public Employee(String name,double salary,Date birthday)
{
this.name=name;
this.salary=salary;
this.birthday=birthday;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name=name;
}
public double getSalary()
{
return salary;
}
public void setSalary(double salary)
{
this.salary=salary;
}
public Date getBirthday()
{
return birthday;
}
public void setBirthday(Date birthday)
{
this.birthday=birthday;
}
}
class Manager extends Employee
{
private double bonus;
public Manager()
{
}
public Manager(String name,double salary,Date birthday,double bonus)
{
super(name,salary,birthday);
this.bonus=bonus;
}
public double getBonus()
{
return bonus;
}
public void setBonus(double bonus)
{
this.bonus=bonus;
}
}
public class Hello
{
public static void main(String[] args)
{
Employee employee=new Employee("java",100,new Date());
Manager manager=new Manager("明日科技",3000,new Date(),2000);
System.out.println(employee.getName());
System.out.println(employee.getSalary());
System.out.println(employee.getBirthday());
System.out.println(manager.getName());
System.out.println(manager.getSalary());
System.out.println(manager.getBirthday());
}
}