package com.itheima;
/**
* 第一题 1、 假如我们在开发一个系统时需要对员工进行建模,员工包含 3 个属性:
* 姓名、工号以及工资。经理也是员工,除了含有员工的属性外,另为还有一个奖金属性。
* 请使用继承的思想设计出员工类和经理类。要求类中提供必要的方法进行属性访问。
* @author Administrator
*
*/
public class Test1 {
public static void main(String[] args)
{
Manager a= new Manager("xxx","2010210004",320.0,50.0);
System.out.println(a.toString());
}
}
class Staff{
private String name;
private String id;
private double wagers;
public String toString()
{
return "姓名:"+name+"" +" 工号:"+id+" 工资:"+wagers;
}
public Staff(String name,String id,double wagers)
{
this.name = name;
this.id = id;
this.wagers = wagers;
}
}
class Manager extends Staff
{
private double bonus;
public String toString()
{
return super.toString()+" 奖金是:"+bonus;
}
Manager(String name,String id,double wagers,double bonus)
{
super(name,id,wagers);
this.bonus = bonus;
}
}
|
|