package otherExam2;
/*
* 假如我们在开发一个系统时需要对员工进行建模,员工包含 3 个属性:姓名、工号以及工资。
* 经理也是员工,除了含有员工的属性外,另为还有一个奖金属性。
* 请使用继承的思想设计出员工类和经理类。要求类中提供必要的方法进行属性访问。
* */
public class Exam1 {
public static void main(String[] args) {
Person p = new Person("李四","12345",1223.22d);
p.dec();
Maner m = new Maner("张经理","99999",201333.11d);
p.dec();
m.setBonus(1234.22d);
m.dec();
m.aec();
System.out.println(m.getBonus());
}
}
class Person
{
public static String name;
public static String ID;
public static double money;
public Person(String name,String ID,double money)
{
this.name =name;
this.ID= ID;
this.money=money;
}
public static void dec()
{
System.out.println("正常工资为"+name+","+ID+","+money);
}
}
class Maner extends Person
{
public Maner(String name, String ID, double money) {
super(name, ID, money);
// TODO Auto-generated constructor stub
this.getBonus();
}
private double bonus;
public double getBonus() {
return bonus;
}
public void setBonus(double bonus) {
this.bonus = bonus;
}
public static void aec()
{
System.out.println("奖金为:");
}
}
|