day17:java基础-项目3---开发团队调度软件

这篇博客介绍了如何使用Java开发一款团队调度软件。主要内容包括需求分析、软件结构设计和代码实现。在软件结构中,定义了员工信息类、设备接口及其实现类,以及员工类和状态类。此外,还创建了NameListService类来管理和操作数据,并实现了异常处理和主界面操作。
摘要由CSDN通过智能技术生成

需求说明

在这里插入图片描述

在这里插入图片描述在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

软件结构设计

在这里插入图片描述在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

代码实现

将员工的基本信息类,data放置在service包中

package myproject03.team.service;

//员工的基本信息
public class Data {
   
    public static final int EMPLOYEE = 10;
    public static final int PROGRAMMER = 11;
    public static final int DESIGNER = 12;
    public static final int ARCHITECT = 13;

    public static final int PC = 21;
    public static final int NOTEBOOK = 22;
    public static final int PRINTER = 23;

    //Employee  :  10, id, name, age, salary
    //Programmer:  11, id, name, age, salary
    //Designer  :  12, id, name, age, salary, bonus
    //Architect :  13, id, name, age, salary, bonus, stock
    public static final String[][] EMPLOYEES = {
   //通过switch-case的方式取值,不会出现数组角标越界的危险
        {
   "10", "1", "马云", "22", "3000"},
        {
   "13", "2", "马化腾", "32", "18000", "15000", "2000"},
        {
   "11", "3", "李彦宏", "23", "7000"},
        {
   "11", "4", "刘强东", "24", "7300"},
        {
   "12", "5", "雷军", "28", "10000", "5000"},
        {
   "11", "6", "任志强", "22", "6800"},
        {
   "12", "7", "柳传志", "29", "10800","5200"},
        {
   "13", "8", "杨元庆", "30", "19800", "15000", "2500"},
        {
   "12", "9", "史玉柱", "26", "9800", "5500"},
        {
   "11", "10", "丁磊", "21", "6600"},
        {
   "11", "11", "张朝阳", "25", "7100"},
        {
   "12", "12", "杨致远", "27", "9600", "4800"}
    };
    
    //如下的EQUIPMENTS数组与上面的EMPLOYEES数组元素一一对应
    //PC      :21, model, display
    //NoteBook:22, model, price
    //Printer :23, name, type 
    public static final String[][] EQUIPMENTS = {
   
        {
   },
        {
   "22", "联想T4", "6000"},
        {
   "21", "戴尔", "NEC17寸"},
        {
   "21", "戴尔", "三星 17寸"},
        {
   "23", "佳能 2900", "激光"},
        {
   "21", "华硕", "三星 17寸"},
        {
   "21", "华硕", "三星 17寸"},
        {
   "23", "爱普生20K", "针式"},
        {
   "22", "惠普m6", "5800"},
        {
   "21", "戴尔", "NEC 17寸"},
        {
   "21", "华硕","三星 17寸"},
        {
   "22", "惠普m6", "5800"}
    };
}

工具类TSUtility放置在view包中

package myproject03.team.view;

import java.util.*;
/**
 * 
 * @Description 项目中提供了TSUtility.java类,可用来方便地实现键盘访问。
 * @author shkstart  Email:shkstart@126.com
 * @version 
 * @date 2019年2月12日上午12:02:58
 *
 */
public class TSUtility {
   
    private static Scanner scanner = new Scanner(System.in);
    /**
     * 
     * @Description 该方法读取键盘,如果用户键入’1’-’4’中的任意字符,则方法返回。返回值为用户键入字符。
     * @author shkstart
     * @date 2019年2月12日上午12:03:30
     * @return
     */
	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;
    }
	/**
	 * 
	 * @Description 该方法提示并等待,直到用户按回车键后返回。
	 * @author shkstart
	 * @date 2019年2月12日上午12:03:50
	 */
    public static void readReturn() {
   
        System.out.print("按回车键继续...");
        readKeyBoard(100, true);
    }
    /**
     * 
     * @Description 该方法从键盘读取一个长度不超过2位的整数,并将其作为方法的返回值。
     * @author shkstart
     * @date 2019年2月12日上午12:04:04
     * @return
     */
    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;
    }
    /**
     * 
     * @Description 从键盘读取‘Y’或’N’,并将其作为方法的返回值。
     * @author shkstart
     * @date 2019年2月12日上午12:04:45
     * @return
     */
    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;
    }

    private 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.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值