Java基础项目 开发团队分配管理系统
先看一下該項目的功能結構:
1.軟件啟動時,首先進入登錄界面進行注冊和登錄功能。
2.當登陸成功后,進入菜單,首先就可以對開發人員賬戶和密碼進行修改。
3.然后可以對開發人員進行增刪改操作
4.人員添加成功后,根據菜單提示,基于現有的公司成員,組建一個開發團隊以開發一個新的項目。
5.組建過程包括將成員插入到團隊中,或從團隊中刪除某成員,還可以列出團隊中現有成員的列表,開發團隊成員包括架構師、設計師和程序員。
6.團隊組建成功,則可以進入項目模塊,添加項目,分配開發團隊進行開發。
主要涉及以下知識點:
1.類的繼承性和多態性
2.對象的值傳遞、接口
3.static和final修飾符
4.特殊類的使用:包裝類、抽象類、內部類
5.異常處理
6.Java基本語法和流程控制
7.數組,ArrayList集合
該軟件由以下三個模塊組成:
com.team.view 模塊為主控模塊,負責菜單的顯示和處理用戶操作
com.team.service 模塊為實體對象(Employee及其子類如程序員等)的管理模塊, NameListService和TeamService類分別用各自的數組來管理公司員工和開發團隊成員對象
ProjectService是對項目的操作對象類
domain模塊為Employee及其子類等JavaBean類所在的包
主要代碼演示
IndexView
private LoginView loginVi = new LoginView();private NameListService nameListSer = new NameListService();private TeamView teamVi = new TeamView();private ProjectService projectSer = new ProjectService();private ArrayList<Programmer[]> manyTeam=null;public void menu() throws TeamException, InterruptedException {boolean loopFlag = true;char key = 0; //系統啟動初始頁面System.out.println(ANSI_PURPLE);System.out.println("🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣");System.out.println("🔣 🔣");System.out.println("🔣 歡迎來到項目開發團隊分配管理軟件 🔣");System.out.println("🔣 🔣");System.out.println("🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣");System.out.println("🐕");System.out.println("🐕");System.out.println("🐕");System.out.println("🐕-----------<請您先進行登錄>-------------🐕");TSUtility.readReturn();try {loginVi.login();} catch (InterruptedException e) {e.printStackTrace();}do {//加死循環,直到用戶退出才退出System.out.println(ANSI_RESET + ANSI_CYAN);System.out.println("🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣");System.out.println("🔣 🔣");System.out.println("🔣 ~軟件主菜單~ 🔣");System.out.println("🔣 🔣");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("?請選擇: ");System.out.print(ANSI_RESET);key = TSUtility.readMenuSelectionPro();switch (key) {//用戶信息修改界面case '1':try {loginVi.update();} catch (InterruptedException e) {e.printStackTrace();}break;//開發人員管理界面,如果覺得代碼太長,可以寫一個方法存儲進去在調用case '2':try {nameListSer.showEmployee();} catch (InterruptedException e) {e.printStackTrace();}boolean loopFlagSec = true;char keySec = 0;do {System.out.print(ANSI_RESET + ANSI_YELLOW);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("?請選擇: ");keySec=TSUtility.readMenuSelectionPro();switch (keySec) {case '1':try {nameListSer.addEmployee();} catch (InterruptedException e) {e.printStackTrace();}break;case '2':try {nameListSer.showEmployee();} catch (InterruptedException e) {e.printStackTrace();}break;case '3':System.out.println("請輸入需要修改的員工id:");int i = TSUtility.readInt();try {nameListSer.modifyEmployee(i);} catch (InterruptedException e) {e.printStackTrace();}break;case '4':System.out.println("請輸入需要刪除的員工id:");int j = TSUtility.readInt();nameListSer.delEmployee(j);break;case '5':System.out.print("確認是否退出(Y/N):");char yn = TSUtility.readConfirmSelection();if (yn == 'Y') {loopFlagSec = false;}break;default:System.out.println("輸入有誤!請重新輸入!");break;}} while (loopFlagSec);break;case '3'://開發團隊調度管理模塊,這個用封裝調用這個方法,下面會顯示方法在哪manyTeam = teamVi.getManyTeam(nameListSer);break;case '4'://開發項目管理模塊boolean loopFlagThr = true;char keyThr = 0;do {System.out.print(ANSI_RESET + ANSI_GREEN);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("?請選擇: ");System.out.print(ANSI_RESET + ANSI_YELLOW);keyThr=TSUtility.readMenuSelectionPro();switch (keyThr) {case '1':try {projectSer.addProject();} catch (InterruptedException e) {e.printStackTrace();}break;case '2':for (Programmer[] pro : manyTeam) {projectSer.dealingPro(pro);}break;case '3':try {projectSer.showPro();} catch (InterruptedException e) {e.printStackTrace();}break;case '4':System.out.println("請輸入需要刪除的項目id:");int j = TSUtility.readInt();projectSer.delPro(j);break;case '5':System.out.print("確認是否退出(Y/N):");char yn = TSUtility.readConfirmSelection();if (yn == 'Y') {loopFlagThr = false;}break;default:System.out.println("輸入有誤!請重新輸入!");break;}} while (loopFlagThr);break;case '5':System.out.print("確認是否退出(Y/N):");char yn = TSUtility.readConfirmSelection();if (yn == 'Y') {loopFlag = false;}break;default:break;}} while (loopFlag);} //主函數,調用這個方法實現public static void main(String[] args) throws TeamException, InterruptedException {new IndexView().menu();}}TeamView模塊
public class TeamView {private TeamService ts = new TeamService();private NameListService n = new NameListService();private ArrayList<Programmer[]> team = new ArrayList<>();//主界面public void MainMenu(){boolean b = true;//顯示輸入列表do {listEmployees();System.out.println("1-團隊列表 2-添加團隊成員 3-刪除團隊成員 4-退出");System.out.println("請選擇(1-4)");char c = TSUtility.readMenuSelection();switch (c) {case '1':listTeam();break;case '2':listEmployees();addMember();break;case '3'://listTeam();DeleteMember();break;case '4':System.out.println("請確認是否退出(Y/N)");char c1 = TSUtility.readConfirmSelection();if (c1 == 'Y') {team.add(ts.getTeam());ts.clearTeam();b = false;}break;default:break;}}while (b);}public ArrayList<Programmer[]> getTeam(){return team;}public void listEmployees(){System.out.println("-----------------開發調度開發軟件-------------------");//獲取所有員工數據ArrayList<Employee> allEmployees = n.getAllEmployees();if (allEmployees.size() == 0) {System.out.println("無員工信息");}else {System.out.println("ID\t 姓名\t年齡\t 工資\t 職位\t 狀態\t 獎金\t 股票\t 領用設備");for (int i = 0; i < allEmployees.size(); i++) {System.out.println(" " + allEmployees.get(i));}}System.out.println("------------------------------------------------");} //getManyTeam這個方法在前面case '2'中調用public ArrayList<Programmer[]> getManyTeam(NameListService x)throws InterruptedException{n=x;boolean flag = true;char key = 0;do{//死循環System.out.println("##########################");System.out.println("##### #####");System.out.println("##### 團隊調度界面 #####");System.out.println("##### #####");System.out.println("##########################");System.out.print("1-添加團隊 2-查看團隊 3-刪除團隊 4-退出 請選擇(1-4):");key = TSUtility.readMenuSelection();System.out.println("---------------------------------------------");switch (key){case '1':MainMenu();break;case '2':System.out.println("----------團隊列表---------");try {if (team.size() == 0) {throw new InterruptedException();} else {System.out.println("ID\t 姓名\t年齡\t\t 工資\t 職位\t 狀態\t 獎金\t 股票\t 領用設備");for (Programmer[] team : team) {for (int i = 0; i < team.length; i++) {System.out.println(team[i]);}System.out.println("======================================================================");}}} catch (InterruptedException i) {System.out.println("當前沒有任何團隊,請重新添加團隊!" + i.getMessage());}break;case '3':System.out.println("請輸入要刪除第幾個團隊");int num = TSUtility.readInt();if (num<=team.size()){System.out.print("確認是否刪除(Y/N):");char de = TSUtility.readConfirmSelection();if (de == 'Y') {team.remove(num-1);}else{System.out.println("請考慮清楚!");}}else {System.out.println("沒有該團隊,請正常輸入!"+"目前團隊只有"+team.size()+"個");}break;case '4':System.out.print("確認是否退出(Y/N):");char yn = TSUtility.readConfirmSelection();if (yn == 'Y') {flag = false;}break;default:break;}}while (flag);return team;}public void listTeam(){System.out.println("-----------------團隊成員列表-------------------");Programmer[] team = ts.getTeam();try {if (team.length == 0) {System.out.println("無開發團隊成員");} else {System.out.println("TeamId/Id\t\t姓名\t\t年齡\t工資\t職位\t獎金\t股票");for (int i = 0; i < team.length; i++) {System.out.println(" " + team[i].getDetailsForTeam());}}System.out.println("------------------------------------------------");}catch (Exception e){System.out.println("開發團隊目前沒有成員");System.out.println("------------------------------------------------");}}//添加成員public void addMember(){System.out.println("請輸入要添加的隊員ID");int ID=TSUtility.readInt();try{Employee e = n.getEmployee(ID);ts.addMember(e);System.out.println("添加成功");}catch (Exception | TeamException e){System.out.println("添加失敗"+e.getMessage());}TSUtility.readReturn();}//刪除成員public void DeleteMember(){System.out.println("---------------------刪除成員---------------------");System.out.print("請輸入要刪除員工的TID:");int id = TSUtility.readInt();System.out.print("確認是否刪除(Y/N):");char yn = TSUtility.readConfirmSelection();if (yn == 'N')return;try {ts.removeMember(id);System.out.println("刪除成功");} catch (TeamException e) {System.out.println("刪除失敗,原因:" + e.getMessage());}// 按回車鍵繼續...TSUtility.readReturn();} }loginView模塊
package com.project1.src.com.team.view;import java.util.Random; import java.util.Scanner;public class LoginView {//首先給定屬性:登錄用戶和密碼private String userName = "";private String password = "";//注冊功能public void regist() throws InterruptedException {TSUtility.loadSpecialEffects();System.out.println("開始注冊:");Scanner sc = new Scanner(System.in);System.out.println("請輸入你的注冊賬戶名稱:");String userName = TSUtility.readKeyBoard(4, false);this.userName = userName;System.out.println("請輸入你的注冊密碼:");String password = TSUtility.readKeyBoard(8, false);this.password = password;System.out.println("注冊成功!請登錄!");}//登錄功能public void login() throws InterruptedException {//登錄失敗的次數限制int count = 5;boolean flag = true;while (flag) {System.out.println("********************🐱");System.out.println("*** <登錄界面> ***");System.out.println("*** (: ***🐱");System.out.println("********************🐱");System.out.println("請輸入你的登錄賬戶名稱:");String userName = TSUtility.readKeyBoard(4, false);System.out.println("請輸入你的登錄密碼:");String password = TSUtility.readKeyBoard(8, false);//未注冊if (this.userName.length() == 0 || this.password.length() == 0) {System.out.println("未檢測到您的賬號,請您先注冊!");regist();}//已注冊//正常登錄else if (this.userName.equals(userName) && this.password.equals(password)) {TSUtility.loadSpecialEffects();System.out.println("登陸成功!歡迎您:" + userName);flag = false;} else {if (count <= 0) {System.out.println("登錄次數不足!退出!");return;} else {count--;System.out.println("登錄失敗!用戶名或密碼不匹配!");System.out.println("登錄次數還剩" + count + "次,請重新輸入:");}}}}//修改功能public void update() throws InterruptedException {boolean flag = true;while (flag) {System.out.println("********************🐱");System.out.println("*** <修改界面> ***");System.out.println("*** (: ***🐱");System.out.println("********************🐱");System.out.println("請輸入你需要修改的類型:");System.out.println("1(修改用戶名)");System.out.println("2(修改密碼名)");System.out.println("3(修改用戶名和密碼名)");System.out.println("4(不修改,退出)");Scanner sc = new Scanner(System.in);String options = sc.next();if (options.equals("1")) {System.out.println("請輸入你的修改的賬戶名稱:");String userName = TSUtility.readKeyBoard(4, false);this.userName = userName;System.out.println("修改成功!");} else if (options.equals("2")) {System.out.println("請輸入你的修改密碼:");String password = TSUtility.readKeyBoard(8, false);this.password = password;System.out.println("修改成功!");} else if (options.equals("3")) {System.out.println("請輸入你的修改的賬戶名稱:");String userName = TSUtility.readKeyBoard(4, false);this.userName = userName;System.out.println("請輸入你的修改密碼:");String password = TSUtility.readKeyBoard(8, false);this.password = password;System.out.println("修改成功!");}else if (options.equals("4")) {System.out.println("退出中");TSUtility.loadSpecialEffects();flag = false;}else {System.out.println("輸入錯誤!請輸入“1”或者“2”或者“3”或者“4”:");}}} }TSUtility模塊,用于輸入
package com.project1.src.com.team.view;import java.util.Random; import java.util.Scanner;public class TSUtility {private static Scanner scanner = new Scanner(System.in);public static char readMenuSelection() {char c;for (; ; ) {String str = readKeyBoard(1, false);c = str.charAt(0);if (c != '1' && c != '2' &&c != '3' && c != '4') {System.out.print("選擇錯誤,請重新輸入:");} else break;}return c;}public static char readMenuSelectionPro() {char c;for (; ; ) {String str = readKeyBoard(1, false);c = str.charAt(0);if (c != '1' && c != '2' &&c != '3' && c != '4' && c != '5') {System.out.print("選擇錯誤,請重新輸入:");} else break;}return c;}public static void readReturn() {System.out.print("按回車鍵繼續...");readKeyBoard(100, true);}public static int readInt() {int n;for (; ; ) {String str = readKeyBoard(2, false);try {n = Integer.parseInt(str);break;} catch (NumberFormatException e) {System.out.print("數字輸入錯誤,請重新輸入:");}}return n;}public static int readstock() {int n;for (; ; ) {String str = readKeyBoard(6, false);try {n = Integer.parseInt(str);break;} catch (NumberFormatException e) {System.out.print("數字輸入錯誤,請重新輸入:");}}return n;}public static Double readDouble() {Double n;for (; ; ) {String str = readKeyBoard(6, false);try {n = Double.parseDouble(str);break;} catch (NumberFormatException e) {System.out.print("數字輸入錯誤,請重新輸入:");}}return n;}public static char readConfirmSelection() {char c;for (; ; ) {String str = readKeyBoard(1, false).toUpperCase();c = str.charAt(0);if (c == 'Y' || c == 'N') {break;} else {System.out.print("選擇錯誤,請重新輸入:");}}return c;}public static String readString(int limit, String defaultValue) {String str = readKeyBoard(limit, true);return str.equals("")? defaultValue : str;}public static String readKeyBoard(int limit, boolean blankReturn) {String line = "";while (scanner.hasNextLine()) {line = scanner.nextLine();if (line.length() == 0) {if (blankReturn) return line;else continue;}if (line.length() < 1 || line.length() > limit) {System.out.print("輸入長度(不大于" + limit + ")錯誤,請重新輸入:");continue;}break;}return line;}public static void loadSpecialEffects() throws InterruptedException {System.out.println("請稍等:");for (int i1 = 1; i1 <= 100; i1++) {System.out.print("加載中:" + i1 + "%");Thread.sleep(new Random().nextInt(25) + 1);if (i1 == 100) {Thread.sleep(50);}System.out.print("\r");}}}總結
以上是生活随笔為你收集整理的Java基础项目 开发团队分配管理系统的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 全球与中国婴儿零食市场深度研究分析报告
- 下一篇: 基于STM32F103单片机的智能婴儿床