java练习题之员工类练习

程序员类:属性(姓名、工号、工资、奖金),行为(工作:软件开发)
测试工程师:属性(姓名、工号、工资),行为(工作:软件测试)
项目经理类:属性(姓名、工号、工资、奖金),行为(工作:控制进度)

package text;
//程序员类:属性(姓名、工号、工资、奖金),行为(工作:软件开发)
//测试工程师:属性(姓名、工号、工资),行为(工作:软件测试)
//项目经理类:属性(姓名、工号、工资、奖金),行为(工作:控制进度)
public class text16 {

	public static void main(String[] args) {
		Employee e=new Programmer("Jack","1",3000);
		Employee e1=new Tester("Rose","2",5000);
		Employee e2=new Manager("Tom","3",8000);
		e.run();
		e1.run();
		e2.run();
	}

}
abstract class Employee{
	String name;
	String id;
	int gongZi;
	public void run() {	
	}
	public Employee(String name, String id, int gongZi) {
		this.name = name;
		this.id = id;
		this.gongZi = gongZi;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public int getGongZi() {
		return gongZi;
	}
	public void setGongZi(int gongZi) {
		this.gongZi = gongZi;
	}
	
}
class Programmer extends Employee{
	public Programmer(String name, String id, int gongZi) {
		super(name, id, gongZi);
	}
	int jiangJin=3000;
	public void run() {
		System.out.println(name+"..."+id+"..."+gongZi+"..."+jiangJin+"...工作:软件开发");
	}
}
class Tester extends Employee{
	public Tester(String name, String id, int gongZi) {
		super(name, id, gongZi);
	}

	public void run() {
		System.out.println(name+"..."+id+"..."+gongZi+"..."+"工作:软件测试");
	}
}
class Manager extends Employee{
	public Manager(String name, String id, int gongZi) {
		super(name, id, gongZi);
	}
	int jiangJin=5000;
	public void run() {
		System.out.println(name+"..."+id+"..."+gongZi+"..."+jiangJin+"...工作:控制进度");
	}
}

你可能感兴趣的:(java)