}
class pro extends employe
{
public void work()
{
System.out.println("pro work");
}
pro(String name,String id,int pay )
{
super(name,id,pay);
}
}
class employee
{
public static void main(String[] args)
{
manager s = new manager("longshao"," 印后"+032,456,12);
System.out.println(s);
pro wu=new pro("wenlong","印后"+032,2500);
System.out.println(wu);
}
}
这个程序运行结果是/*假如我们开发一个程序需要对公司的员工建模,员工的属性包括:姓名 工号 工资 经理也是员工,除了含有员工的属性外,
还有一个奖金的属性,请使用继承的思想设计出员工类和经理类,要求类中提供必要的方法进行属性的访问
员工类: name id pay
经理类: 继承了员工类中的name id pay ,另外还有bonus属性
**/
abstract class employe
{
private String name;
private String id;
private double pay;
employe(String name,String id,int pay)
{
this.name=name;
this.id=id;
this.pay=pay;
}
public abstract void work();
}
class manager extends employe
{
public void work()
{
System.out.println("manager work");
}
private double bonus;
manager(String name,String id,int pay,int bonus)
{
super(name,id,pay);
this.bonus=bonus;
}
}
class pro extends employe
{
public void work()
{
System.out.println("pro work");
}
pro(String name,String id,int pay )
{
super(name,id,pay);
}
}
class employee
{
public static void main(String[] args)
{
manager s = new manager("longshao"," 印后"+032,456,12);
System.out.println(s);
pro wu=new pro("wenlong","印后"+032,2500);
System.out.println(wu);
}
}
/*假如我们开发一个程序需要对公司的员工建模,员工的属性包括:姓名 工号 工资 经理也是员工,除了含有员工的属性外,
还有一个奖金的属性,请使用继承的思想设计出员工类和经理类,要求类中提供必要的方法进行属性的访问
员工类: name id pay
经理类: 继承了员工类中的name id pay ,另外还有bonus属性
**/
abstract class employe
{
private String name;
private String id;
private double pay;
employe(String name,String id,int pay)
{
this.name=name;
this.id=id;
this.pay=pay;
}
public abstract void work();
}
class manager extends employe
{
public void work()
{
System.out.println("manager work");
}
private double bonus;
manager(String name,String id,int pay,int bonus)
{
super(name,id,pay);
this.bonus=bonus;
}
}
class pro extends employe
{
public void work()
{
System.out.println("pro work");
}
pro(String name,String id,int pay )
{
super(name,id,pay);
}
}
class employee
{
public static void main(String[] args)
{
manager s = new manager("longshao"," 印后"+032,456,12);
System.out.println(s);
pro wu=new pro("wenlong","印后"+032,2500);
System.out.println(wu);
}
}
/*假如我们开发一个程序需要对公司的员工建模,员工的属性包括:姓名 工号 工资 经理也是员工,除了含有员工的属性外,
还有一个奖金的属性,请使用继承的思想设计出员工类和经理类,要求类中提供必要的方法进行属性的访问
员工类: name id pay
经理类: 继承了员工类中的name id pay ,另外还有bonus属性
**/
abstract class employe
{
private String name;
private String id;
private double pay;
employe(String name,String id,int pay)
{
this.name=name;
this.id=id;
this.pay=pay;
}
public abstract void work();
}
class manager extends employe
{
public void work()
{
System.out.println("manager work");
}
private double bonus;
manager(String name,String id,int pay,int bonus)
{
super(name,id,pay);
this.bonus=bonus;
}
}
class pro extends employe
{
public void work()
{
System.out.println("pro work");
}
pro(String name,String id,int pay )
{
super(name,id,pay);
}
}
class employee
{
public static void main(String[] args)
{
manager s = new manager("longshao"," 印后"+032,456,12);
System.out.println(s);
pro wu=new pro("wenlong","印后"+032,2500);
System.out.println(wu);
}
}
/*假如我们开发一个程序需要对公司的员工建模,员工的属性包括:姓名 工号 工资 经理也是员工,除了含有员工的属性外,
还有一个奖金的属性,请使用继承的思想设计出员工类和经理类,要求类中提供必要的方法进行属性的访问
员工类: name id pay
经理类: 继承了员工类中的name id pay ,另外还有bonus属性
**/
abstract class employe
{
private String name;
private String id;
private double pay;
employe(String name,String id,int pay)
{
this.name=name;
this.id=id;
this.pay=pay;
}
public abstract void work();
}
class manager extends employe
{
public void work()
{
System.out.println("manager work");
}
private double bonus;
manager(String name,String id,int pay,int bonus)
{
super(name,id,pay);
this.bonus=bonus;
}
}
class pro extends employe
{
public void work()
{
System.out.println("pro work");
}
pro(String name,String id,int pay )
{
super(name,id,pay);
}
}
class employee
{
public static void main(String[] args)
{
manager s = new manager("longshao"," 印后"+032,456,12);
System.out.println(s);
pro wu=new pro("wenlong","印后"+032,2500);
System.out.println(wu);