设为首页 加入收藏

TOP

开发人员调度软件(七)
2019-09-02 23:33:20 】 浏览:85
Tags:开发 人员 调度 软件
uot;找不到该成员,删除失败!"); } for (int j = i+1; j < total; j++) { //往前覆盖 team[j-1] = team[j]; } team[--total] = null; } private boolean isExit(Programmer p){ for (int i = 0; i < total; i++) { if (team[i].getId() == p.getId()){ return true; } } return false; } }

Utils

TSUtility.java

package pers.jsc.dispatch.utils;

import java.util.*;

/**
 * @author shkstart  Email:shkstart@126.com
 * @Description 项目中提供了TSUtility.java类,可用来方便地实现键盘访问。
 * @date 2019年2月12日上午12:02:58
 */
public class TSUtility {
    private static Scanner scanner = new Scanner(System.in);

    /**
     * @return 返回值为用户键入1’-’4’中的字符。
     * @Description 该方法读取键盘,如果用户键入’1’-’4’中的任意字符,则方法返回。
     * @author shkstart
     * @date 2019年2月12日上午12:03:30
     */
    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 void readReturn() {
        System.out.print("按回车键继续...");
        readKeyBoard(100, true);
    }

    /**
     * @return 返回键盘读取不超过2位的整数
     * @Description 该方法读一个长度不超过2位的整数。
     * @author shkstart
     * @date 2019年2月12日上午12:04:04
     */
    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;
    }

    /**
     * @return 返回键盘读取‘Y’或’N’
     * @Description 从键盘读取‘Y’或’N’,并将其作为方法的返回值。
     * @author shkstart
     * @date 2019年2月12日上午12:04:45
     */
    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.length() > limit) {
                System.out.print("输入长度(不大于" + limit + ")错误,请重新输入:");
                continue;
            }
            break;
        }

        return line;
    }
}

View

TeamView.java

package pers.jsc.dispatch.view;

import pers.jsc.dispatch.domain.Employee;
import pers.jsc.dispatch.domain.domainexte.Programmer;
import pers.jsc.dispatch.exception.TeamException;
import pers.jsc.dispatch.service.NameListService;
import pers.jsc.dispatch.service.TeamService;
import pers.jsc.dispatch.utils.TSUtility;

/**
 * @author 金聖聰
 * @title: TeamView
 * @projectName TeamDispatchApp
 * @description: TODO
 * @date 2019/5/9 18:21
 */
public class TeamView {
    /**
     * 供类中的方法使用
     */
    private NameListService listSvc = new NameListService();
    private TeamService teamSvc = new TeamService();

    /**
     * 主界面显示及控制方法
     */
    public void enterMainMenu() {
        boolean flag = true;
        char key = '0';
        do {

            char loop = '1';
            if (key != loop) {
                listAllEmployees();
            }


            System.out.print("1-团队列表  2-添加团队成员  3-删除团队成员 4-退出   请选择(1-4):");
            key = TSUtility.readMenuSelection();
            switch (key) {
                case '1':
                    getTeam();
                    break;
                case '2':
                    addMember();
                    break;
                case '3':
                    deleteMember();
                    break;
                case '4':
                    System.out.print("确认是否退出(Y/N):");
                    char notExit = 'N';
                    flag = TSUtility.
首页 上一页 4 5 6 7 8 下一页 尾页 7/8/8
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Java断点续传(基于socket与Rando.. 下一篇一起来学Spring Cloud | 第三章:..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目