开发团队组建项目_准备二:工具类及原始数据类
作者:互联网
package com.it.team.view;
/*工具类*/
import java.util.*;
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 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 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;
}
}
```原始数据类型:
package com.it.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 = {
{"10", "1", "马云\t", "22", "3000"},
{"13", "2", "马化腾", "32", "18000", "15000", "2000"},
{"11", "3", "李彦宏", "23", "7000"},
{"11", "4", "刘强东", "24", "7300"},
{"12", "5", "雷军\t", "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", "丁磊\t", "21", "6600"},
{"11", "11", "张朝阳", "25", "7100"},
{"12", "12", "杨志远", "27", "9600", "4800"}
};
//PC :21, model, display
//NoteBook:22, model, price
//Printer :23, type, name
//员工设备二维数组与雇员信息二维数组一一对应, 存储的是每个雇员的设备信息
public static final String[][] EQUIPMENTS = {
{},
{"22", "联想Y5", "6000"},
{"21", "宏碁 ", "AT7-N52"},
{"21", "戴尔", "3800-R33"},
{"23", "激光", "佳能 2900"},
{"21", "华硕", "K30BD-21寸"},
{"21", "海尔", "18-511X 19"},
{"23", "针式", "爱普生20K"},
{"22", "惠普m6", "5800"},
{"21", "联想", "ThinkCentre"},
{"21", "华硕","KBD-A54M5 "},
{"22", "惠普m6", "5800"}
};
}
标签:11,21,int,组建,final,static,类及,原始数据,public 来源: https://blog.csdn.net/qmxqing/article/details/118004306