将java测试卷重新完成,测试完后基本完成需求,无明显BUG
结合课堂上去写这个java测试卷,总的来说,之前没有独立写过类似项目+限时是比较大的问题。
如果之前没有经历类似的情况,很多功能都是第一次用,那么就会导致出现bug而不知道如何去改,并且加上时间限制,如果时间全花在改bug上,又无法完成项目的需求。
除此之外,如果没有项目经验,那么还会导致项目一开始的结构就很混乱,无法做到逐渐实现一块块功能,而是直接从上到下直接垒。
public class Main {public static void main(String[] args) {Planmanager pm = new Planmanager();pm.page();}
}class PlaneInformation {private int id;private String planid;//日报流水号,依次加一。private String planname;//产品名称private String process;//当前工序名称private String nextprocess;//下一接收工序名称private String operator;//当前工序的操作者private String recipient;//下一道工序的接受者private int plannumber;//该产品定要要求的产品数量private int innumber;//从上一道工序的接收的合格产品总数private int outnumber;//当前工序的产品转出总数private int missnumber;//当前工序的产品丢失数量private int badnumber;//前工序的产品废品数量private int inspectednubmer;//当前工序的产品待检验数量private int statement;//表示该日报记录的状态,0表示初始计划,1表示日报提交,2表示日报确认。public PlaneInformation() {}public void PlaneInformation(int id, String planid, String planname, String process, String nextprocess, String operator, String recipient, int plannumber, int innumber, int outnumber, int missnumber, int badnumber, int inspectednubmer, int statement) {this.id = id;this.planid = planid;this.planname = planname;this.process = process;this.nextprocess = nextprocess;this.operator = operator;this.recipient = recipient;this.plannumber = plannumber;this.innumber = innumber;this.outnumber = outnumber;this.missnumber = missnumber;this.badnumber = badnumber;this.inspectednubmer = inspectednubmer;this.statement = statement;}public void PlaneInformation() {}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getPlanid() {return planid;}public void setPlanid(String planid) {this.planid = planid;}public String getPlanname() {return planname;}public void setPlanname(String planname) {this.planname = planname;}public String getProcess() {return process;}public void setProcess(String process) {this.process = process;}public String getNextprocess() {return nextprocess;}public void setNextprocess(String nextprocess) {this.nextprocess = nextprocess;}public String getOperator() {return operator;}public void setOperator(String operator) {this.operator = operator;}public String getRecipient() {return recipient;}public void setRecipient(String recipient) {this.recipient = recipient;}public int getPlannumber() {return plannumber;}public void setPlannumber(int plannumber) {this.plannumber = plannumber;}public int getInnumber() {return innumber;}public void setInnumber(int innumber) {this.innumber = innumber;}public int getOutnumber() {return outnumber;}public void setOutnumber(int outnumber) {this.outnumber = outnumber;}public int getMissnumber() {return missnumber;}public void setMissnumber(int missnumber) {this.missnumber = missnumber;}public int getBadnumber() {return badnumber;}public void setBadnumber(int badnumber) {this.badnumber = badnumber;}public int getInspectednubmer() {return inspectednubmer;}public void setInspectednubmer(int inspectednubmer) {this.inspectednubmer = inspectednubmer;}public int getStatement() {return statement;}public void setStatement(int statement) {this.statement = statement;}
}import java.util.Scanner;
class Person
{int id;String Theworkname;String operator;public Person(int id, String theworkname, String operator) {this.id = id;Theworkname = theworkname;this.operator = operator;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getTheworkname() {return Theworkname;}public void setTheworkname(String theworkname) {Theworkname = theworkname;}public String getOperator() {return operator;}public void setOperator(String operator) {this.operator = operator;}
}public class Planmanager {PlaneInformation planeInformation[] = new PlaneInformation[1000];Person person[] = new Person[15];int idd = 0;public void page() {person[1] = new Person(1, "10.射蜡", "羽");person[2] = new Person(2, "20.修蜡", "哲");person[3] = new Person(3, "30.面层", "诺");person[4] = new Person(4, "40.封浆", "铎");person[5] = new Person(5, "50.熔化", "恒");person[6] = new Person(6, "60.切割", "印");person[7] = new Person(7, "70.精磨", "文");person[8] = new Person(8, "80.调型", "正");person[9] = new Person(9, "90.检验", "静");person[10] = new Person(10, "0.无", "无");person[11] = new Person(11, "-1.无", "无");boolean k = true;Scanner scc = new Scanner(System.in);while (k) {//主页面System.out.println("***********************************************************");System.out.println("石家庄铁道大学无限23软件开发有限公司");System.out.println("Mes系统2023版");System.out.println("***********************************************************");System.out.println("1、生成计划");System.out.println("2、提交日报");System.out.println("3、确认日报");System.out.println("4、统计进度");System.out.println("5.退出系统");int Thechoice = scc.nextInt();switch (Thechoice) {//1、生成计划"case 1: {Creatework();break;}//2、提交日报case 2: {{Submitreport();}break;}//3、确认日报case 3: {Confirmreport();break;}//4、统计进度case 4: {Statisticprogress();break;}//退出系统case 5: {k = false;break;}default: {System.out.println("该选项不存在");}}}}public void Creatework() {boolean kk = true;while (kk) {Scanner sc = new Scanner(System.in);System.out.println("产品批次:");String planid = sc.next();while (planid.length() < 8 || planid.charAt(4) != '-') {System.out.println("输入有问题,请重新输入产品批次号");planid = sc.next();}System.out.println("产品名称:");String planename1 = sc.next();System.out.println("计划数量:");int plannumber1 = sc.nextInt();System.out.println("产品批次" + planid);System.out.println("产品名称“" + planename1);System.out.println("计划数量" + plannumber1);System.out.println("该产品入库操作已完成,是否提交(Y/N)");String yesno = sc.next();planeInformation[0] = new PlaneInformation();if (yesno.equals("Y")) {planeInformation[0].setPlanid(planid);planeInformation[0].setPlanname(planename1);planeInformation[0].setPlannumber(plannumber1);planeInformation[0].setStatement(0);planeInformation[0].setInnumber(plannumber1);System.out.println("提交成功!");kk = false;}}}public void Submitreport() {Scanner sc = new Scanner(System.in);System.out.println("请输入产品序列号");String planid = sc.next();for (int i = 0; i < planeInformation.length; i++) {if (planeInformation[i].getPlanid().equals(planid)) {if (planeInformation[i].getStatement() == 0) {System.out.println("1.产品批次:" + planeInformation[i].getPlanid());System.out.println("2.产品名称:" + planeInformation[i].getPlanname());System.out.println("3.计划数量:" + planeInformation[i].getPlannumber());planeInformation[i].setProcess(person[1].Theworkname);System.out.println("4.当前工序:"+planeInformation[i].getProcess());planeInformation[i].setNextprocess(person[2].Theworkname);System.out.println("5.下一工序:"+planeInformation[i].getNextprocess());planeInformation[i].setOperator(person[1].operator);planeInformation[i].setRecipient(person[2].operator);System.out.println("6.操作员:" + planeInformation[i].getOperator());System.out.println("7.接收员:" + planeInformation[i].getRecipient());System.out.println("8.上一道工序转入数量:"+planeInformation[i].getInnumber());System.out.println("9.转出总数:");int outnumber = sc.nextInt();System.out.println("10.丢失数量:");int missnumber = sc.nextInt();System.out.println("11.废品数量:");int badnumber = sc.nextInt();System.out.println("12.待检验数量:");int inspectednubmer = sc.nextInt();while (planeInformation[i].getInnumber() != outnumber + missnumber + badnumber + inspectednubmer) {System.out.println("录入错误信息,请重新输入以下信息");System.out.println("9.转出总数:");outnumber = sc.nextInt();System.out.println("10.丢失数量:");missnumber = sc.nextInt();System.out.println("11.废品数量:");badnumber = sc.nextInt();System.out.println("12.待检验数量:");inspectednubmer = sc.nextInt();}System.out.println("选择“Y”将修改信息保存提交。选择“N”,不保存修改信息");String yesno1 = sc.next();if (yesno1.equals("Y")) {planeInformation[i].setOutnumber(outnumber);planeInformation[i].setMissnumber(missnumber);planeInformation[i].setBadnumber(badnumber);planeInformation[i].setInspectednubmer(inspectednubmer);planeInformation[i].setStatement(1);planeInformation[i].setId(idd);System.out.println("提交成功");}break;} else if (planeInformation[i].getStatement() == 2) {System.out.println("1.产品批次:" + planeInformation[i].getPlanid());System.out.println("2.产品名称:" + planeInformation[i].getPlanname());System.out.println("3.计划数量:" + planeInformation[i].getPlannumber());System.out.println("4.当前工序:" + planeInformation[i].getProcess());System.out.println("5.下一工序:" + planeInformation[i].getNextprocess());System.out.println("6.操作员:" + planeInformation[i].getOperator());System.out.println("7.接收员:" + planeInformation[i].getRecipient());System.out.println("8.上一道工序转入数量:" + planeInformation[i].getInnumber());System.out.println("9.转出总数:");int outnumber = sc.nextInt();System.out.println("10.丢失数量:");int missnumber = sc.nextInt();System.out.println("11.废品数量:");int badnumber = sc.nextInt();System.out.println("12.待检验数量:");int inspectednubmer = sc.nextInt();while (planeInformation[i].getInnumber() != outnumber + missnumber + badnumber + inspectednubmer) {System.out.println("录入错误信息,请重新输入以下信息");System.out.println("9.转出总数:");outnumber = sc.nextInt();System.out.println("10.丢失数量:");missnumber = sc.nextInt();System.out.println("11.废品数量:");badnumber = sc.nextInt();System.out.println("12.待检验数量:");inspectednubmer = sc.nextInt();}System.out.println("选择“Y”将修改信息保存提交。选择“N”,不保存修改信息");String yesno1 = sc.next();if (yesno1.equals("Y")) {planeInformation[i].setOutnumber(outnumber);planeInformation[i].setMissnumber(missnumber);planeInformation[i].setBadnumber(badnumber);planeInformation[i].setInspectednubmer(inspectednubmer);planeInformation[i].setStatement(1);System.out.println("提交成功");}break;}} else {System.out.println("库中没有该产品计划");}}}public void Confirmreport() {Scanner sc = new Scanner(System.in);System.out.println("请输入产品序列号");String planid = sc.next();for (int i = 0; i < planeInformation.length; i++) {if (planeInformation[i].getPlanid().equals(planid)) {if (planeInformation[i].getStatement() == 1) {System.out.println("1.产品批次:" + planeInformation[i].getPlanid());System.out.println("2.产品名称:" + planeInformation[i].getPlanname());System.out.println("3.计划数量:" + planeInformation[i].getPlannumber());System.out.println("4.当前工序:" + planeInformation[i].getProcess());System.out.println("5.下一工序:" + planeInformation[i].getNextprocess());System.out.println("6.操作员:" + planeInformation[i].getOperator());System.out.println("7.接收员:" + planeInformation[i].getRecipient());System.out.println("8.上一道工序转入数量:" + planeInformation[i].getInnumber());System.out.println("9.转出总数:" + planeInformation[i].getOutnumber());System.out.println("10.丢失数量:" + planeInformation[i].getMissnumber());System.out.println("11.废品数量:" + planeInformation[i].getBadnumber());System.out.println("12.待检验数量:" + planeInformation[i].getInspectednubmer());System.out.println("选择Y/N来确认结果");String yesno1 = sc.next();if (yesno1.equals("Y")) {planeInformation[i].setStatement(2);planeInformation[i].setProcess(planeInformation[i].getNextprocess());planeInformation[i].setOperator(planeInformation[i].getRecipient());planeInformation[i].setInnumber(planeInformation[i].getOutnumber());char x = planeInformation[i].getNextprocess().charAt(0);int xx = x - '0';planeInformation[i].setNextprocess(person[xx + 1].getTheworkname());planeInformation[i].setRecipient(person[xx + 1].getOperator());System.out.println("确认成功");}System.out.println("1.产品批次:" + planeInformation[i].getPlanid());System.out.println("2.产品名称:" + planeInformation[i].getPlanname());System.out.println("3.计划数量:" + planeInformation[i].getPlannumber());System.out.println("4.当前工序:" + planeInformation[i].getProcess());System.out.println("5.下一工序:" + planeInformation[i].getNextprocess());System.out.println("6.操作员:" + planeInformation[i].getOperator());System.out.println("7.接收员:" + planeInformation[i].getRecipient());System.out.println("8.上一道工序转入数量:" + planeInformation[i].getInnumber());System.out.println("9.转出总数:" + planeInformation[i].getOutnumber());System.out.println("10.丢失数量:" + planeInformation[i].getMissnumber());System.out.println("11.废品数量:" + planeInformation[i].getBadnumber());System.out.println("12.待检验数量:" + planeInformation[i].getInspectednubmer());break;}else {System.out.println("请先提交日报");break;}}}}public void Statisticprogress() {Scanner sc = new Scanner(System.in);System.out.println("请输入产品序列号");String planid = sc.next();for (int i = 0; i < planeInformation.length; i++) {if (planeInformation[i].getPlanid().equals(planid)) {System.out.println("1.产品批次:" + planeInformation[i].getPlanid());System.out.println("2.产品名称:"+planeInformation[i].getPlanname());System.out.println("3.计划数量:"+planeInformation[i].getPlannumber());char x = planeInformation[i].getProcess().charAt(0);int xx = x - '0';if(xx==0){System.out.println("4.完成数量:"+planeInformation[i].getOutnumber());System.out.println("5.剩余数量"+(planeInformation[i].getPlannumber()-planeInformation[i].getOutnumber()));}else{System.out.println("4.完成数量:"+0);System.out.println("5.剩余数量"+(planeInformation[i].getPlannumber()));}break;}}}
}