团队分配管理系统

import com.team.service.NameListService;
import com.team.service.ProjectService;
import com.team.service.TeamException;

import java.util.Scanner;

public class IndexView {
    public static void main(String[] args) throws TeamException {
        Scanner sc = new Scanner(System.in);
        String useName = null;
        String passWord = null;
        LoginView login = new LoginView();
        login.register(useName, passWord);
        int x = 0;
        while (x != 5) {
            System.out.println("🍟🍟🍟🍟🍟主界面🍟🍟🍟🍟🍟");
            System.out.println("🍙1.修改用户信息");
            System.out.println("🍳2.开发人员管理");
            System.out.println("🍿3.开发团队调度管理");
            System.out.println("🌺4.开发项目管理");
            System.out.println("🥗5.退出软件");
            System.out.println("🍳请输入你的选择:");
            x = sc.nextInt();
            switch (x) {
                case 1:
                    login.updateUsename(useName, passWord);
                    break;
                case 2:
                    NameListService nls = new NameListService();
                    nls.nlsMain();
                    break;
                case 3:
                    TeamView tv=new TeamView();
                    tv.teamDispatch();
                    break;
                case 4:
                    ProjectService ps=new ProjectService();
                    ps.psMain();
                    break;
                case 5:
                    System.out.println("请确认是否退出:输入Y/N");
                    char yn = sc.next().charAt(0);
                    while (yn != 'Y' && yn != 'N') {
                        try {
                            throw new TeamException("请输入Y/N重新确认:");
                        } catch (TeamException t) {
                            System.out.println(t.getMessage());
                            yn = sc.next().charAt(0);
                        }
                    }
                    if (yn == 'N') {
                        x = 0;
                    }
                default:
                    break;
            }
        }
    }
}
import java.util.Scanner;

public class LoginView {

    public void register(String useName,String passWord) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            if (useName==null) {
                System.out.println("🏓🏓🏓🏓🏓🏓🏓🏓🏓🏓");
                System.out.println("🥞请先注册账号:");
                System.out.print("用户名:");
                useName = sc.next();
                System.out.print("密码:");
                passWord = sc.next();
            } else {
                for (int i = 0; i < 5; i++) {
                    String usename;
                    String password;
                    System.out.println("🎈请登录你的账号:");
                    System.out.print("用户名:");
                    usename = sc.next();
                    System.out.print("密码:");
                    password = sc.next();
                    if (useName.equals(usename) && passWord.equals(password)) {
                        System.out.println("🎪🎪🎪登陆成功,欢迎" + useName+"🎪🎪🎪");
                        return;
                    } else {
                        System.out.println("输入错误,你还有" + (4 - i) + "次机会");
                        if (i == 4) {
                            System.exit(0);
                        }
                    }
                }
            }
        }
    }

    public void updateUsename(String useName,String passWord){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入新的账号和密码:");
        System.out.print("用户名:");
        useName = sc.next();
        System.out.print("密码:");
        passWord = sc.next();
        register(useName, passWord);
    }
}

public class TeamView {
        NameListService nls=new NameListService();
        static TeamService ts=new TeamService();
        static ArrayList<Programmer[]> ap = new ArrayList<>();

    public ArrayList<Programmer[]> getAp() {
        return ap;
    }

    public void teamDispatch() throws TeamException {
        Scanner sc = new Scanner(System.in);
        int x = 0;
        while (x != 4) {
            System.out.println("------------------------开发团队调度软件------------------------");
            nls.check();
            System.out.println("🎇🎇🎇🎇🎇🎇🎇🎇🎇🎇🎇🎇");
            System.out.println("🎇   团队调度界面   🎇");
            System.out.println("🎇🎇🎇🎇🎇🎇🎇🎇🎇🎇🎇🎇");
            System.out.print("1.查看团队\t");
            System.out.print("2.添加团队\t");
            System.out.print("3.删除团队\t");
            System.out.print("4.退出当前菜单\t");
            System.out.print("请选择1-4:");
            x = sc.nextInt();
            switch (x) {
                case 1:
                    for (int i=0;i<ap.size();i++){
                        ts.checkTeam(ap.get(i));
                    }
                    break;
                case 2:
                    ts.teamMain();
                    break;
                case 3:

                    break;
                case 4:
                    System.out.println("请确认是否退出:输入Y/N");
                    char yn = sc.next().charAt(0);
                    while (yn != 'Y' && yn != 'N') {
                        try {
                            throw new TeamException("请输入Y/N重新确认:");
                        } catch (TeamException t) {
                            System.out.println(t.getMessage());
                            yn = sc.next().charAt(0);
                        }
                    }
                    if (yn == 'N') {
                        x = 0;
                    }
                    break;
                default:
                    System.out.println("输入错误,请重新输入");
                    break;
            }
        }
    }

    public void removeTeam(){
        Scanner sc = new Scanner(System.in);
        System.out.println("你要删除第几个团队?");
        int x=sc.nextInt();
        ap.remove(x-1);
    }
}

import com.team.domain.Programmer;

public class addTeamException {
    public void judge(int i,int p,int d,int a,Programmer[] team) throws TeamException {
        NameListService nls = new NameListService();
        if (p+d+a==5) {
            throw new TeamException("成员已满无法添加");
        } else if (nls.getEmployee(i).getClass().getSimpleName() .equals( "Employee")) {
            throw new TeamException("该成员不是开发人员,无法添加");
        } else if (!((Programmer)nls.getEmployee(i)).isStatus()) {
            throw new TeamException("该员工已是某团队成员");
        }  else if (a==1&&nls.getEmployee(i).getClass().getSimpleName().equals( "Architect")) {
            throw new TeamException("团队中至多只能有一名架构师");
        } else if (d==2&&nls.getEmployee(i).getClass().getSimpleName().equals( "Designer")) {
            throw new TeamException("团队中至多只能有两名设计师");
        } else if (p==3&&nls.getEmployee(i).getClass().getSimpleName().equals( "Programmer")) {
            throw new TeamException("团队中至多只能有三名程序员");
        }else if(i<=0||i>nls.getAllEmployees().size()){
            throw new TeamException("没有该id的成员");
        }
    }
}
import com.team.domain.*;

import java.util.ArrayList;
import java.util.Scanner;

public class NameListService {
    Scanner sc = new Scanner(System.in);
    private static ArrayList<Employee> employees = new ArrayList<>();
    static int count = 1;

    public void nlsMain() throws TeamException {
        Scanner sc = new Scanner(System.in);
        int x = 0;
        while (x != 5) {
            System.out.println("------------------------开发团队调度软件------------------------");

            System.out.println("1.查看开发人员");
            System.out.println("2.添加开发成员");
            System.out.println("3.删除开发成员");
            System.out.println("4.修改开发人员");
            System.out.println("5.退出当前菜单");
            System.out.println("请选择1-4:");
            x = sc.nextInt();
            switch (x) {
                case 1:
                    check();
                    break;
                case 2:
                    addEmployee();
                    break;
                case 3:
                    deleteEmployee();
                    break;
                case 4:
                    updateEmployee();
                    break;
                case 5:
                    System.out.println("请确认是否退出:输入Y/N");
                    char yn = sc.next().charAt(0);
                    while (yn != 'Y' && yn != 'N') {
                        try {
                            throw new TeamException("请输入Y/N重新确认:");
                        } catch (TeamException t) {
                            System.out.println(t.getMessage());
                            yn = sc.next().charAt(0);
                        }
                    }
                    if (yn == 'N') {
                        x = 0;
                    }
                    break;
                default:
                    System.out.println("输入错误,请重新输入");
                    break;
            }
        }
    }

    static {
        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(++count, "杨元庆", 35, 6500, new Printer("针式", "爱普生20k"), 15500, 1200));
        employees.add(new Designer(++count, "史玉柱", 27, 7800, new NoteBook("惠普m6", 5800), 1500));
        employees.add(new Programmer(++count, "丁磊 ", 26, 6600, new PC("戴尔", "NEC17寸")));
        employees.add(new Programmer(++count, "张朝阳 ", 35, 7100, new PC("华硕", "三星 17寸")));
        employees.add(new Designer(++count, "杨致远", 38, 9600, new NoteBook("惠普m6", 5800), 3000));
    }


    public ArrayList<Employee> getAllEmployees() {
        return employees;
    }

    public Employee getEmployee(int id) throws TeamException {
        while (id<=0&&id > employees.get(employees.size() - 1).getId()) {
            try {
                throw new TeamException("输入错误,请重新输入:");
            } catch (TeamException t) {
                System.out.println(t.getMessage());
                id = sc.nextInt();
            }
        }
        return employees.get(id - 1);
    }

    public void addEmployee() {
        System.out.println("请问要添加的成员是什么职位?");
        System.out.println("1(无职位)");
        System.out.println("2(程序员)");
        System.out.println("3(设计师)");
        System.out.println("4(架构师)");
        int position = sc.nextInt();
        switch (position) {
            case 1:
                Employee ae = new Employee();
                ae.setId(++count);
                System.out.println("请输入你要添加的");
                ae.setName(sc.next());
                System.out.println("请输入你要添加的");
                ae.setAge(sc.nextInt());
                System.out.println("请输入你要添加的");
                ae.setSalary(sc.nextInt());
                employees.add(ae);
                break;
            case 2:
                Programmer ap = new Programmer();
                ap.setId(++count);
                System.out.println("请输入你要添加的姓名");
                ap.setName(sc.next());
                System.out.println("请输入你要添加的年龄");
                ap.setAge(sc.nextInt());
                System.out.println("请输入你要添加的工资");
                ap.setSalary(sc.nextInt());
                PC pc = new PC();
                System.out.println("请输入你要添加的设备型号");
                pc.setModel(sc.next());
                System.out.println("请输入你要添加的显示器名称");
                pc.setDisplay(sc.next());
                ap.setEquipment(pc);
                employees.add(ap);
                break;
            case 3:
                Designer ad = new Designer();
                ad.setId(++count);
                System.out.println("请输入你要添加的姓名");
                ad.setName(sc.next());
                System.out.println("请输入你要添加的年龄");
                ad.setAge(sc.nextInt());
                System.out.println("请输入你要添加的工资");
                ad.setSalary(sc.nextInt());
                NoteBook nb = new NoteBook();
                System.out.println("请输入你要添加的设备型号");
                nb.setModel(sc.next());
                System.out.println("请输入你要添加的设备价格");
                nb.setPrice(sc.nextInt());
                ad.setEquipment(nb);
                System.out.println("请输入你要添加的奖金");
                ad.setBonus(sc.nextInt());
                employees.add(ad);
                break;
            case 4:
                Architect aa = new Architect();
                aa.setId(++count);
                System.out.println("请输入你要添加的姓名");
                aa.setName(sc.next());
                System.out.println("请输入你要添加的年龄");
                aa.setAge(sc.nextInt());
                System.out.println("请输入你要添加的工资");
                aa.setSalary(sc.nextInt());
                Printer p = new Printer();
                System.out.println("请输入你要添加的设备名字");
                p.setName(sc.next());
                System.out.println("请输入你要添加的设备类型");
                p.setType(sc.next());
                aa.setEquipment(p);
                System.out.println("请输入你要添加的奖金");
                aa.setBonus(sc.nextInt());
                System.out.println("请输入你要添加的股票");
                aa.setStock(sc.nextInt());
                employees.add(aa);
                break;
        }
    }

    public void deleteEmployee() throws TeamException {
        System.out.println("请输入你要删除的成员的id:");
        int deleteID = sc.nextInt();
        employees.remove(deleteID - 1);
        for (int i = deleteID; i <= getAllEmployees().size(); i++) {
            getEmployee(i).setId(getEmployee(i).getId() - 1);
        }
        count--;
    }

    public void updateEmployee() throws TeamException {
        System.out.println("请输入你要修改的成员的id:");
        int updateID = sc.nextInt();
        if (getEmployee(updateID).getClass().getSimpleName().equals("Programmer")) {
            Programmer ap = new Programmer();
            ap.setId(++count);
            System.out.println("请输入新的姓名");
            ap.setName(sc.next());
            System.out.println("请输入新的年龄");
            ap.setAge(sc.nextInt());
            System.out.println("请输入新的工资");
            ap.setSalary(sc.nextInt());
            PC pc = new PC();
            System.out.println("请输入新的设备型号");
            pc.setModel(sc.next());
            System.out.println("请输入新的显示器名称");
            pc.setDisplay(sc.next());
            ap.setEquipment(pc);
            employees.set(updateID, ap);
        } else if (getEmployee(updateID).getClass().getSimpleName().equals("Designer")) {
            Designer ad = new Designer();
            ad.setId(++count);
            System.out.println("请输入新的姓名");
            ad.setName(sc.next());
            System.out.println("请输入新的年龄");
            ad.setAge(sc.nextInt());
            System.out.println("请输入新的工资");
            ad.setSalary(sc.nextInt());
            NoteBook nb = new NoteBook();
            System.out.println("请输入新的设备型号");
            nb.setModel(sc.next());
            System.out.println("请输入新的设备价格");
            nb.setPrice(sc.nextInt());
            ad.setEquipment(nb);
            System.out.println("请输入新的奖金");
            ad.setBonus(sc.nextInt());
            employees.set(updateID, ad);
        } else if (getEmployee(updateID).getClass().getSimpleName().equals("Architect")) {
            Architect aa = new Architect();
            aa.setId(++count);
            System.out.println("请输入新的姓名");
            aa.setName(sc.next());
            System.out.println("请输入新的年龄");
            aa.setAge(sc.nextInt());
            System.out.println("请输入新的工资");
            aa.setSalary(sc.nextInt());
            Printer p = new Printer();
            System.out.println("请输入新的设备名字");
            p.setName(sc.next());
            System.out.println("请输入新的设备类型");
            p.setType(sc.next());
            aa.setEquipment(p);
            System.out.println("请输入新的奖金");
            aa.setBonus(sc.nextInt());
            System.out.println("请输入新的股票");
            aa.setStock(sc.nextInt());
            employees.set(updateID, aa);
        }
    }

    public void check() {
        System.out.println("ID\t姓名\t\t年龄\t工资\t\t状态\t\t奖金\t\t股票\t\t设备");
        for (int i = 0; i < getAllEmployees().size(); i++) {
            System.out.println(getAllEmployees().get(i).toString());
        }
    }
}
import com.team.domain.Project;
import com.team.view.TeamView;

import java.util.ArrayList;
import java.util.Scanner;

public class ProjectService {
    ArrayList<Project> pro = new ArrayList<>();
    int count = 1;
    TeamView tv = new TeamView();
    TeamService ts = new TeamService();

    public void psMain() throws TeamException {
        Scanner sc = new Scanner(System.in);
        int x = 0;
        while (x != 5) {
            System.out.println("🎭开发项目管理主菜单🎭");

            System.out.println("1.查看项目");
            System.out.println("2.添加项目");
            System.out.println("3.删除项目");
            System.out.println("4.项目分配开发团队");
            System.out.println("5.退出当前菜单");
            System.out.println("请选择1-4:");
            x = sc.nextInt();
            switch (x) {
                case 1:
                    checkPro();
                    break;
                case 2:
                    addPro();
                    break;
                case 3:
                    removePro();
                    break;
                case 4:
                    distributePro();
                    break;
                case 5:
                    System.out.println("请确认是否退出:输入Y/N");
                    char yn = sc.next().charAt(0);
                    while (yn != 'Y' && yn != 'N') {
                        try {
                            throw new TeamException("请输入Y/N重新确认:");
                        } catch (TeamException t) {
                            System.out.println(t.getMessage());
                            yn = sc.next().charAt(0);
                        }
                    }
                    if (yn == 'N') {
                        x = 0;
                    }
                    break;
                default:
                    System.out.println("输入错误,请重新输入");
                    break;
            }
        }
    }

    public void checkPro() {
        System.out.println("🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃");
        System.out.println(String.format("%-6s", "项目号") + String.format("%-6s", "项目名称") + String.format("%-16s", "项目描述") + String.format("%-8s", "状态")+String.format("%-8s", "团队名称"));
        for (int i = 0; i < pro.size(); i++) {
            System.out.print(String.format("%-8s", pro.get(i).getProId()));
            System.out.print(String.format("%-8s", pro.get(i).getProjectName()));
            System.out.print(String.format("%-18s", pro.get(i).getDesName()));
            System.out.print(String.format("%-8s", pro.get(i).isStatus()));
            System.out.println(String.format("%-8s", pro.get(i).getTeamName()));
        }
        System.out.println("🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃🎃");
    }

    public void addPro() {
        Scanner sc = new Scanner(System.in);
        Project p = new Project();
        p.setProId(count++);
        System.out.println("请输入你要添加的项目名称:");
        p.setProjectName(sc.next());
        System.out.println("请输入该项目的项目描述:");
        p.setDesName(sc.next());
//        System.out.println("你要添加第几个开发团队?");
//        int x = sc.nextInt();
//        p.setTeam(tv.getAp().get(x - 1));
//        System.out.println("请给这个开发团队取个名称:");
//        p.setTeamName(sc.next());
        pro.add(p);
    }

    public void removePro(){
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入你要删除的项目号:");
        int deleteProID = sc.nextInt();
        pro.remove(deleteProID-1);
        for (int i = deleteProID-1; i < pro.size(); i++) {
            pro.get(i).setProId(i+1);
        }
        count--;
    }

    public void distributePro() throws TeamException {
        Scanner sc=new Scanner(System.in);
        checkPro();
        System.out.println("请问要为第几号项目分配团队");
        int proNum=sc.nextInt();
        while(proNum<=0||proNum>pro.size()||pro.get(proNum-1).isStatus()){
            try {
                if(proNum<=0||proNum>pro.size()){
                    throw new TeamException("没有这个项目,请重新输入:");
                }else {
                    throw new TeamException("这个项目正在开发,请重新输入:");
                }
            }catch (TeamException t){
                System.out.println(t.getMessage());
                proNum=sc.nextInt();
            }
        }
        for (int i = 0; i < tv.getAp().size(); i++) {
            ts.checkTeam(tv.getAp().get(i));
        }
        System.out.println("请问要为该项目分配第几个团队");
        int teamNum=sc.nextInt();
        while (teamNum<=0||teamNum>tv.getAp().size()){
            try {
                throw new TeamException("没有这个团队,请重新输入:");
            }catch (TeamException t){
                System.out.println(t.getMessage());
                teamNum=sc.nextInt();
            }
        }
        pro.get(proNum-1).setTeam(tv.getAp().get(teamNum-1));
        System.out.println("请为该团队起个名字:");
        pro.get(proNum-1).setTeamName(sc.next());
        pro.get(proNum-1).setStatus(true);
    }
}

public class TeamException extends Exception{
    public TeamException() {
    }

    public TeamException(String message) {
        super(message);
    }
}
import com.team.domain.Architect;
import com.team.domain.Designer;
import com.team.domain.Programmer;
import com.team.view.TeamView;

import javax.jws.soap.SOAPBinding;
import java.util.Scanner;

public class TeamService {

    int counter = 1;
    int pCount = 0;
    int dCount = 0;
    int aCount = 0;
    int total = 0;
    static TeamView tv = new TeamView();
    NameListService nls = new NameListService();

    public void teamMain() throws TeamException {
        pCount = 0;
        dCount = 0;
        aCount = 0;
        total = 0;
        Scanner sc = new Scanner(System.in);
        final int MAX_MEMBER = 5;
        Programmer[] team = new Programmer[MAX_MEMBER];
        tv.getAp().add(team);
        int x = 0;
        while (x != 4) {

            System.out.print("1.团队列表\t");
            System.out.print("2.添加团队成员\t");
            System.out.print("3.删除团队成员\t");
            System.out.print("4.退出当前菜单\t");
            System.out.print("请选择1-4:");
            x = sc.nextInt();
            switch (x) {
                case 1:
                    for (int i = 0; i < tv.getAp().size(); i++) {
                        checkTeam(tv.getAp().get(i));
                    }
                    break;
                case 2:
//                    ,pCount, dCount, aCount,total
                    addMenber(team);
                    break;
                case 3:
                    removeMenber();
                    break;
                case 4:
                    System.out.println("请确认是否退出:输入Y/N");
                    char yn = sc.next().charAt(0);
                    while (yn != 'Y' && yn != 'N') {
                        try {
                            throw new TeamException("请输入Y/N重新确认:");
                        } catch (TeamException t) {
                            System.out.println(t.getMessage());
                            yn = sc.next().charAt(0);
                        }
                    }
                    if (yn == 'N') {
                        x = 0;
                    }
                    break;
                default:
                    System.out.println("输入错误,请重新输入");
                    break;
            }
        }
    }


    public void checkTeam(Programmer[] team) {
        System.out.println("--------------------------团队列表--------------------------");
        System.out.println(String.format("%-10s", "TID/ID") + "姓名\t\t年龄\t工资\t\t职位\t\t\t奖金\t\t股票");
        for (int i = 0; i < team.length; i++) {
            if (team[i] instanceof Programmer) {
                System.out.print(team[i].getMemberId() + "/" + String.format("%-8s", team[i].getId()));
                System.out.print(String.format("%-8s", team[i].getName()));
                System.out.print(team[i].getAge() + "\t");
                System.out.print(team[i].getSalary() + "\t");
                System.out.print(team[i].getClass().getSimpleName() + "\t");
            }
            if (team[i] instanceof Designer) {
                System.out.print(((Designer) team[i]).getBonus() + "\t");
            }
            if (team[i] instanceof Architect) {
                System.out.print(((Architect) team[i]).getStock());
            }
            System.out.println();
        }
        System.out.println("----------------------------------------------------------");
//        System.out.println(tv.getAp().get(tv.getAp().size() - 1)[tv.getAp().get(tv.getAp().size() - 1).length-1].getMemberId() );
//        System.out.println(tv.getAp().size() - 1);
//        System.out.println(tv.getAp().get(tv.getAp().size() - 1).length-1);
//        System.out.println(total);

    }

    //,int pCount,int dCount,int aCount,int total
    public void addMenber(Programmer[] team) throws TeamException {
        NameListService nls = new NameListService();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你要添加成员的id:");
        int i = sc.nextInt();

        try {
            addTeamException ate = new addTeamException();
            ate.judge(i, pCount, dCount, aCount, team);
            team[total] = (Programmer) nls.getEmployee(i);
            team[total].setMemberId(counter);
            counter++;
            total++;
            ((Programmer) nls.getEmployee(i)).setStatus(false);
            if (nls.getEmployee(i).getClass().getSimpleName().equals("Programmer")) {
                pCount++;
            } else if (nls.getEmployee(i).getClass().getSimpleName().equals("Designer")) {
                dCount++;
            } else if (nls.getEmployee(i).getClass().getSimpleName().equals("Architect")) {
                aCount++;
            }
        } catch (TeamException t) {
            System.out.println("添加失败,原因:" + t.getMessage());
        }
    }

        public void removeMenber() throws TeamException {

        System.out.println("请输入你要删除成员的TID:");
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        while (x <= 0 && x > tv.getAp().get(tv.getAp().size() - 1)[total - 1].getMemberId()) {
            try {
                throw new TeamException("没有这个TID,请重新输入:");
            } catch (TeamException t) {
                System.out.println(t.getMessage());
                x = sc.nextInt();
            }
        }
        int xTeam = 0;
        int element = 0;
//        int primaryID=0;
//        for (int i = 0; i < tv.getAp().size();i++) {
//            if (x <= tv.getAp().get(xTeam+i)[tv.getAp().get(xTeam+i).length-1].getMemberId()) {
//                    primaryID = tv.getAp().get(xTeam + i)[x - 1].getId();
//                    break;
//            }else {
//                x=x-tv.getAp().get(xTeam+i).length;
//            }
//        }
        for (int n = 0; n < 5; n++) {
            if (tv.getAp().get(xTeam)[n] != null) {
                element++;
            } else {
                break;
            }
        }
        for (int i = x - 1; i < tv.getAp().get(tv.getAp().size() - 1)[total - 1].getMemberId(); i++) {

            if (x > element) {
                xTeam++;
                x = 1;
                element = 0;
                for (int n = 0; n < 5; n++) {
                    if (tv.getAp().get(xTeam)[n] != null) {
                        element++;
                    } else {
                        break;
                    }
                }
            }

            if (xTeam == 0) {
                if (x == element) {
//                tv.getAp().get(xTeam+1)[0].setMemberId(i+1);
//                tv.getAp().get(xTeam)[x-1] = tv.getAp().get(xTeam+1)[0];
                    tv.getAp().get(xTeam)[x - 1] = null;
                    tv.getAp().get(xTeam + 1)[0].setMemberId(i);
                } else {
                    tv.getAp().get(xTeam)[x].setMemberId(i + 1);
                    tv.getAp().get(xTeam)[x - 1] = tv.getAp().get(xTeam)[x];
                }
                x++;
            } else {
                tv.getAp().get(xTeam)[x - 1].setMemberId(i);
                x++;
            }
        }
        if (tv.getAp().size() == 1) {
            tv.getAp().get(xTeam)[x - 1] = null;
        }
        counter--;
        total--;
//        ((Programmer)nls.getEmployee(primaryID)).setStatus(true);
    }
}

public interface Equipment {
    String getDescription();
}
public class PC implements Equipment{
    private String model;
    private String display;

    public PC() {
    }

    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 toString() {
        return  model  + "\t" + display ;
    }

    @Override
    public String getDescription() {
        return toString();
    }
}

public class NoteBook implements Equipment{
    private String model;
    private double price;

    public NoteBook() {
    }

    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 toString() {
        return  model  + "\t" + price ;
    }

    @Override
    public String getDescription() {
        return toString();
    }
}

public class Printer implements Equipment{
    private String name;
    private String type;

    public Printer() {
    }

    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 toString() {
        return name + "\t" + type ;
    }

    @Override
    public String getDescription() {
        return toString();
    }
}
public class Employee {
    private int id;
    private String name;
    private int age;
    private double 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;
    }

    public Employee(int id, String name, int age, double salary) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.salary = salary;
    }

    public Employee() {
    }

    @Override
    public String toString() {
        return  id + "\t" + name  + "\t" + age + "\t" + salary  ;
    }
}
public class Programmer extends Employee {
    private int memberId;
    private boolean status = true;
    private Equipment equipment;

    public Programmer(int id, String name, int age, double salary,  Equipment equipment) {
        super(id, name, age, salary);
        this.equipment = equipment;
    }

    public Programmer() {
    }

    public int getMemberId() {
        return memberId;
    }

    public void setMemberId(int memberId) {
        this.memberId = memberId;
    }

    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 String getDetail(){
        return super.toString() + "\t" + status  ;
    }

    @Override
    public String toString() {
        return getDetail()+ "\t\t\t\t\t" + equipment.toString();
    }
}
public class Designer extends Programmer{
    private double bonus;

    public Designer() {
    }

    public Designer(int id, String name, int age, double salary,  Equipment equipment, double bonus) {
        super(id, name, age, salary,  equipment);
        this.bonus = bonus;
    }

    public double getBonus() {
        return bonus;
    }

    public void setBonus(double bonus) {
        this.bonus = bonus;
    }

    public String getDetail(){
        return super.getDetail()+"\t" + bonus;
    }
    @Override
    public String toString() {
        return getDetail()+"\t\t\t"+getEquipment().toString()  ;
    }
}

public class Architect extends Designer {
    private int stock;

    public Architect() {
    }

    public Architect(int id, String name, int age, double salary, Equipment equipment, double bonus, int stock) {
        super(id, name, age, salary, equipment, bonus);
        this.stock = stock;
    }

    public int getStock() {
        return stock;
    }

    public void setStock(int stock) {
        this.stock = stock;
    }

    public String getDetail() {
        return super.getDetail()+"\t"+stock;
    }

    @Override
    public String toString() {
        return getDetail() + "\t" + getEquipment().toString();
    }
}

public class Project {
    private int proId;
    private String projectName;
    private String desName;
    private Programmer[] team;
    private String teamName;
    private boolean status=false;

    public Project() {
    }

    public Project(int proId, String projectName, String desName, Programmer[] team, String teamName, boolean status) {
        this.proId = proId;
        this.projectName = projectName;
        this.desName = desName;
        this.team = team;
        this.teamName = teamName;
        this.status = status;
    }

    public int getProId() {
        return proId;
    }

    public void setProId(int proId) {
        this.proId = proId;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    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;
    }
}

遇到的问题

1.关于null和空字符串

当我String str;后,后面要用到str时,他会报错说要先初始化。然后问了同学才知道要创建一个空的String时,要在后面=null。String str和String str=null是不一样的。他们跟String str=" "也不一样。

2.关于多态转型

当有个集合的类型为父类的时候,你要存个子类的对象时,要向下转型。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值