代码结构:
package com.atguigu.team.domain;
public interface Equipment {
String getDescription();
}
package com.atguigu.team.domain;
public class NoteBook implements Equipment{
private String model;//机器的型号
private double price;//价格
public NoteBook() {
super();
}
public NoteBook(String model, double price) {
super();
this.model = model;
this.price = price;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
@Override
public String getDescription() {
return model + "(" + price + ")";
}
}
package com.atguigu.team.domain;
public class PC implements Equipment{
private String model;//机器型号
private String display;//显示器名称
public PC() {
super();
}
public PC(String model, String display) {
super();
this.model = model;
this.display = display;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getDisplay() {
return display;
}
public void setDisplay(String display) {
this.display = display;
}
@Override
public String getDescription() {
return model + "(" + display + ")";
}
}
package com.atguigu.team.domain;
public class Printer implements Equipment{
private String name;//名称
private String type;//机器的类型
public Printer() {
super();
}
public Printer(String name, String type) {
super();
this.name = name;
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String getDescription() {
return name + "(" + type + ")";
}
}
package com.atguigu.team.domain;
public class Employee {
private int id;
private String name;
private int age;
private double salary;
public Employee() {
}
public Employee(int id, String name, int age, double salary) {
this.id = id;
this.name = name;
this.age = age;
this.salary = salary;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
protected String getDetails() {
return id + "\t" + name + "\t" + age+ "\t" +salary;
}
@Override
public String toString() {
return getDetails();
}
}
package com.atguigu.team.domain;
import com.atguigu.team.service.*;
public class Programmer extends Employee {
private int memberId;
private Status status = Status.FREE;
private Equipment equipment;
public Programmer() {
}
public Programmer(int id, String name, int age,
double salary, Equipment equipment) {
super(id, name, age, salary);
this.equipment = equipment;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public Equipment getEquipment()