正式开学第一天
今天上午上了《算法与数据结构》的第一节课,刘丹老师先是给我们讲了这个课程重要性,然后讲了一些数据结构的概念。
紧接着上了陈晶晶的《马克思主义原理》,讲了一些事实作为引子,下节课准备讲课本上的内容。
下午,验收暑期的Java学习成果,进行Java的测验。
这是我在课上完成的代码
package xiangmu;
public class PlanInformation {
// 私有变量定义
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 inspectednumber;
private int statement;
public PlanInformation(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 inspectednumber, 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.inspectednumber = inspectednumber;
this.statement = statement;
}
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 getInspectednumber() {
return inspectednumber;
}
public void setInspectednumber(int inspectednumber) {
this.inspectednumber = inspectednumber;
}
public int getStatement() {
return statement;
}
public void setStatement(int statement) {
this.statement = statement;
}
}
package xiangmu;
import java.util.Scanner;
public class PlanManagement {
private PlanInformation[] plans = new PlanInformation[5];
private int currentIndex = 0;
//生成计划
public void shengcheng() {
if (currentIndex >= plans.length) {
System.out.println("存储已满.");
return;
}
Scanner scanner = new Scanner(System.in);
System.out.println("请输入产品批次:");
String planid = scanner.nextLine();
if (!planid.matches("\\d{4}-\\d{3}")) {
System.out.println("录入错误,请重新录入正确的信息。");
return;
}
System.out.println("请输入产品名称:");
String planname = scanner.nextLine();
System.out.println("请输入计划数量:");
int plannumber = scanner.nextInt();
scanner.nextLine();
PlanInformation newPlan = new PlanInformation(
currentIndex + 1, planid, planname, "10. 射蜡", "20. 修蜡", "柳泽羽", "藤艺哲", plannumber, 0, 0, 0, 0, 0, 0
);
System.out.println("***********************************************************");
System.out.println("产品批次:" + planid);
System.out.println("产品名称:" + planname);
System.out.println("计划数量:" + plannumber);
System.out.println("该产品入库操作已完成,是否提交(Y/N)");
System.out.println("***********************************************************");
String choice = scanner.nextLine();
if (choice.equalsIgnoreCase("Y")) {
plans[currentIndex] = newPlan;
currentIndex++;
System.out.println("计划已保存。");
} else {
System.out.println("计划录入取消。");
}
}
// 提交日报
public void tijiao() {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入产品批次号:");
String planid = scanner.nextLine();
PlanInformation plan = findPlanById(planid);
if (plan == null) {
System.out.println("库中没有该产品计划。");
return;
}
if (plan.getStatement() != 0) {
System.out.println("该产品批次已提交。");
return;
}
System.out.println("产品批次:" + plan.getPlanid());
System.out.println("产品名称:" + plan.getPlanname());
System.out.println("计划数量:" + plan.getPlannumber());
System.out.println("当前工序:" + plan.getProcess());
System.out.println("下一工序:" + plan.getNextprocess());
System.out.println("操作员:" + plan.getOperator());
System.out.println("接收员:" + plan.getRecipient());
System.out.println("请输入转出总数:");
int outnumber = scanner.nextInt();
plan.setOutnumber(outnumber);
System.out.println("请输入丢失数量:");
int missnumber = scanner.nextInt();
plan.setMissnumber(missnumber);
System.out.println("请输入废品数量:");
int badnumber = scanner.nextInt();
plan.setBadnumber(badnumber);
System.out.println("请输入待检验数量:");
int inspectednumber = scanner.nextInt();
plan.setInspectednumber(inspectednumber);
if (plan.getPlannumber() !=outnumber + missnumber + badnumber + inspectednumber) {
System.out.println("录入错误.");
return;
}
plan.setStatement(1);
System.out.println("日报已提交.");
}
//确认日报
public void queren() {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入产品批次号:");
String planid = scanner.nextLine();
PlanInformation plan = findPlanById(planid);
if (plan == null||plan.getStatement() != 1) {
System.out.println("没有该产品计划.");
return;
}
System.out.println("产品批次:" + plan.getPlanid());
System.out.println("产品名称:" + plan.getPlanname());
System.out.println("计划数量:" + plan.getPlannumber());
System.out.println("当前工序:" + plan.getProcess());
System.out.println("下一工序:" + plan.getNextprocess());
plan.setStatement(2);
System.out.println("日报已确认.");
}
// 统计进度
public void tongji() {
for (PlanInformation plan : plans) {
if (plan != null) {
int completed = plan.getOutnumber();
int remaining = plan.getPlannumber() - completed;
System.out.println("***********************************************************");
System.out.println("产品批次:" + plan.getPlanid());
System.out.println("产品名称:" + plan.getPlanname());
System.out.println("计划数量:" + plan.getPlannumber());
System.out.println("完成数量:" + completed);
System.out.println("剩余数量:" + remaining);
System.out.println("***********************************************************");
}
}
}
private PlanInformation findPlanById(String planid) {
for (PlanInformation plan : plans) {
if (plan != null && plan.getPlanid().equals(planid)) {
return plan;
}
}
return null;
}
// 主界面
public void myMenu() {
Scanner scanner = new Scanner(System.in);
while (true) {
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("***********************************************************");
System.out.println("请输入选择的功能编号(1-4):");
int choice = scanner.nextInt();
scanner.nextLine();
switch (choice) {
case 1:
shengcheng();
break;
case 2:
tijiao();
break;
case 3:
queren();
break;
case 4:
tongji();
break;
default:
System.out.println("该选项不存在,请重新输入.");
break;
}
}
}
}
package xiangmu;
public class Main {
public static void main(String[] args) {
PlanManagement management = new PlanManagement();
management.myMenu();
}
}
代码还存在一些问题,需要改进。
标签:报告,int,2024.9,System,plan,println,public,out From: https://www.cnblogs.com/wangzilin0507/p/18405220