/**
* @param args
*/
public static void main(String[] args) {
//用继承,重写方法,都是调用的wages()方法
Person personManager = new Manager()
System.out.println("这个人的工资是:"+personManager.wages())
Person personEngineer = new Engineer()
System.out.println("这个人的工资是:"+personEngineer.wages())
Person personWorker = new Worker()
System.out.println("这个人的工资是:"+personWorker.wages())
}
}
//人类
class Person {
public String wages(){
return ""
}
}
//经理类
class Manager extends Person{
public String wages(){
return "5000/月"
}
}
//工程师类
class Engineer extends Person{
public String wages(){
return "3000/月"
}
}
//工人类
class Worker extends Person{
public String wages(){
return "2000/月"
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)