首先,欢迎大家愿意点开链接进来学习,当然博主也希望从小伙伴的评论中学习,共同进步。
下面是各类的主要代码块:
下面展示一些 内联代码片
。
一.domian包:
Employee 雇员类
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 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 int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
protected String getDetails() {
return id + "\t" + name + "\t" + age+ "\t\t" +salary;
}
@Override
public String toString() {
return id + "\t"+name + "\t"+age+"\t\t" + salary;
}
}
Programmer 程序员类
package team.domain;
//程序员
public class Programmer extends Employee {
private int memberld;//用来记录成员加入开发团队在再团队中的ID
private boolean status = true;//status 是项目中人员的状态,先赋值为true,当添加到团队时为false
private Equipment 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 int getMemberld() {
return memberld;
}
public void setMemberld(int memberld) {
this.memberld = memberld;
}
public boolean isStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
public Equipment getEquipment() {
return equipment;
}
public void setEquipment(Equipment equipment) {
this.equipment = equipment;
}
public boolean getStatus() {
return status;
}
public String getDetailsTeam(){
return getMemberld()+"/"+getDetails()+"\t程序员";
}
@Override
public String toString() {
return getDetails() +"\t"+"\t程序员\t"+ status +"\t"+ "\t\t\t\t\t\t"+equipment.getDescription();
}
}
Designer 设计师类:
package team.domain;
//设计师
public class Designer extends Programmer{
private double bouns;//表示奖金
public Designer() {
}
public Designer(int id, String name, int age, double salary, Equipment equipment, double bouns) {
super(id, name, age, salary, equipment);
this.bouns = bouns;
}
public double getBouns() {
return bouns;
}
public void setBouns(double bouns) {
this.bouns = bouns;
}
public String getDetailsTeam(){
return getMemberld()+"/"+getDetails()+"\t设计师\t"+getBouns();
}
@Override
public String toString() {
return getDetails()+"\t\t设计师\t"+getStatus()+"\t"+getBouns()+"\t\t\t\t\t"+getEquipment().getDescription();
}
}
Architect 架构师类:
package team.domain;
//架构师
public class Architect extends Designer {
private int stock;//表示公司奖励的股票数量
public Architect() {
}
public Architect(int id, String name, int age, double salary, Equipment equipment, double bouns, int stock) {
super(id, name, age, salary, equipment, bouns);
this.stock = stock;
}
public int getStock() {
return stock;
}
public void setStock(int stock) {
this.stock = stock;
}
public String getDetailsTeam(){
return getMemberld()+"/"+getDetails()+"\t架构师\t"+getBouns()+"\t\t"+getStock();
}
@Override
public String toString() {
return getDetails()+"\t"+"\t架构师\t"+getStatus()+"\t"+getBouns()+"\t\t"+getStock()+"\t\t"+getEquipment().getDescription();
}
}
接口 Equipment
package team.domain;
//接口
public interface Equipment {
String getDescription();
}
PC 实现接口
package team.domain;
//台式电脑
public class PC implements Equipment{
private String model;//表示机器型号
private String display;//表示显示机器名称
public PC(String model, String display) {
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;
}
}
NoteBook 实现接口
package team.domain;
//笔记本电脑
public class NoteBook implements Equipment {
private String model;//表示机器型号
private double price;
public NoteBook(String model, double price) {
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;
}
}
Printer 实现接口
package team.domain;
//打印机
public class Printer implements Equipment{
private String name;
private String type;//表示机器类型
public Printer(String name, String type) {
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;
}
}
Project 类
package team.domain;
public class Project {
private int prold;//项目号
private String projictName;//项目名称
private String desName;//项目描述
private Programmer[] team;//开发团队(指员工)
private String teamName;//开发团队名称
private boolean status;//开发状态 true为开发中
public int getProld() {
return prold;
}
public void setProld(int prold) {
this.prold = prold;
}
public String getProjictName() {
return projictName;
}
public void setProjictName(String projictName) {
this.projictName = projictName;
}
public String getDesName() {
return desName;
}
public void setDesName(String desName) {
this.desName = desName;
}
public Programmer[] getTeam() {
return team;
}
public void setTeam(Programmer[] team) {
this.team = team;
}
public String getTeamName() {
return teamName;
}
public void setTeamName(String teamName) {
this.teamName = teamName;
}
public boolean isStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
public Project() {
}
public Project(int prold, String projictName, String desName, Programmer[] team, String teamName, boolean status) {
this.prold = prold;
this.projictName = projictName;
this.desName = desName;
this.team = team;
this.teamName = teamName;
this.status = status;
}
public String des() {
return "项目{" +
"项目号='"+prold+'\'' +
"项目名='" + projictName + '\'' +
", 项目描述='" + desName + '\'' +
", 开发团队名称='" + teamName + '\'' +
", 开发状态=" + status +
'}'+"\n";
}
@Override
public String toString() {
des();
if (status)
{
return "项目【" + projictName + "】"+ "---->正在被团队【" + teamName + "】开发中!";
}else
{
return des()+"项目【" + projictName + "】---->"+ "未被开发!";
}
}
}
二. service
NameListService 类
package team.service;
import team.domain.*;
import team.view.TSUtility;
import java.util.ArrayList;
import java.util.Scanner;
public class NameListService {
Scanner sc = new Scanner(System.in);
private ArrayList<Employee> employees = new ArrayList<>();
//添加员工的id
private int count = 1;
//初始化默认值
{
employees.add(new Employee(count, "马云 ", 22, 3000));
employees.add(new Architect(++count, "马化腾", 32, 18000, new NoteBook("联想T4", 6000), 60000, 5000));
employees.add(new Programmer(++count, "李彦宏", 23, 7000, new PC("戴尔", "NEC 17寸")));
employees.add(new Programmer(++count, "刘强东", 24, 7300, new PC("戴尔", "三星 17寸")));
employees.add(new Designer(++count, "雷军 ", 50, 10000, new Printer("激光", "佳能2900"), 5000));
employees.add(new Programmer(++count, "任志强", 30, 16800, new PC("华硕", "三星 17寸")));
employees.add(new Designer(++count, "柳传志", 45, 35500, new PC("华硕", "三星 17寸"), 8000));
employees.add(new Architect(