首页 > 其他分享 >9.15(开学考试)

9.15(开学考试)

时间:2023-09-17 21:59:03浏览次数:38  
标签:开学 String 9.15 System sc println public 考试 out

  WarehouseInformation.java
1 package kaoshi; 2 3 import java.util.Scanner; 4 public class WarehouseInformation { 5 private String itemno; //表示商品编号(有8 位数字组成) 6 private String itemname; //表示商品名称 7 private String suppliername; //表示供货商名称 8 private String warehousingtime; //表示入库时间,长度八位 9 private String shipmenttime; //表示出库时间,长度八位 10 private String warehousenumber; //表示仓库编号,长度三位 11 private String warehouseplace; //表示存放商品的具体位置,长度八位数字XXXXYYZZ,其中XXXX表示货架号,YY表示货架的层号,ZZ表示存放在该货架该层的商品顺序号 12 private int itemnumber; //表示入库商品的数量 13 private int outnumber = 0; //表示出库商品的数量 14 15 public WarehouseInformation() { 16 } 17 18 public WarehouseInformation(String itemno, String itemname, String suppliername, String warehousingtime, String shipmenttime, String warehousenumber, String warehouseplace, int itemnumber, int outnumber) { 19 this.itemno = itemno; 20 this.itemname = itemname; 21 this.suppliername = suppliername; 22 this.warehousingtime = warehousingtime; 23 this.shipmenttime = shipmenttime; 24 this.warehousenumber = warehousenumber; 25 this.warehouseplace = warehouseplace; 26 this.itemnumber = itemnumber; 27 this.outnumber = outnumber; 28 } 29 30 31 32 33 34 35 36 37 38 public String getItemno() { 39 return itemno; 40 } 41 42 43 44 45 46 public void setItemno(String itemno) { 47 this.itemno = itemno; 48 } 49 50 51 52 53 54 public String getItemname() { 55 return itemname; 56 } 57 58 59 60 61 62 public void setItemname(String itemname) { 63 this.itemname = itemname; 64 } 65 66 67 68 69 70 public String getSuppliername() { 71 return suppliername; 72 } 73 74 75 76 77 78 public void setSuppliername(String suppliername) { 79 this.suppliername = suppliername; 80 } 81 82 83 84 85 86 public String getWarehousingtime() { 87 return warehousingtime; 88 } 89 90 91 92 93 94 public void setWarehousingtime(String warehousingtime) { 95 this.warehousingtime = warehousingtime; 96 } 97 98 99 100 101 102 public String getShipmenttime() { 103 return shipmenttime; 104 } 105 106 107 108 109 110 public void setShipmenttime(String shipmenttime) { 111 this.shipmenttime = shipmenttime; 112 } 113 114 115 116 117 118 public String getWarehousenumber() { 119 return warehousenumber; 120 } 121 122 123 124 125 126 public void setWarehousenumber(String warehousenumber) { 127 this.warehousenumber = warehousenumber; 128 } 129 130 131 133 134 public String getWarehouseplace() { 135 return warehouseplace; 136 } 137 138 139 140 141 142 public void setWarehouseplace(String warehouseplace) { 143 this.warehouseplace = warehouseplace; 144 } 145 146 147 149 150 public int getItemnumber() { 151 return itemnumber; 152 } 153 154 155 156 157 158 public void setItemnumber(int itemnumber) { 159 this.itemnumber = itemnumber; 160 } 161 162 163 164 165 166 public int getOutnumber() { 167 return outnumber; 168 } 169 170 171 172 173 174 public void setOutnumber(int outnumber) { 175 this.outnumber += outnumber; 176 } 177 178 public void show(){ 179 System.out.println("1.商品编号:" + this.itemno); 180 System.out.println("2.商品名称:" +this.itemname ); 181 System.out.println("3.供货商信息:" + this.suppliername); 182 System.out.println("4.入库时间:" + this.warehousingtime); 183 System.out.println("5.存放仓库号:" + this.warehousenumber); 184 System.out.println("6.存放位置信息:" + this.warehouseplace); 185 System.out.println("7.入库商品数量:" + this.itemnumber); 186 } 187 188 189 // return "WarehouseInformation{itemno = " + itemno + ", itemname = " + itemname + ", suppliername = " + suppliername + ", warehousingtime = " + warehousingtime + ", shipmenttime = " + shipmenttime + ", warehousenumber = " + warehousenumber + ", warehouseplace = " + warehouseplace + ", itemnumber = " + itemnumber + ", outnumber = " + outnumber + "}"; 190 // } 191 }
WarehouseMangagement.java
  1 package kaoshi;
  2 
  3 import java.util.Scanner;
  4 
  5 public class WarehouseManagement {
  6     public static void main(String[] args) {
  7         WarehouseInformation[] s = new WarehouseInformation[5];
  8         WarehouseInformation s1 = new WarehouseInformation("20223766","aaa","aaa","00000000","00000001","001","00000000",100,10);
  9         WarehouseInformation s2 = new WarehouseInformation("20223767","bbb","bbb","00000001","00000002","002","00000001",100,20);
 10         WarehouseInformation s3 = new WarehouseInformation("20223768","ccc","ccc","00000002","00000003","005","00000002",100,30);
 11         WarehouseInformation s4 = new WarehouseInformation("20223769","dd","dd","00000003","00000004","004","00000003",100,40);
 12         s[0] = s1;
 13         s[1] = s2;
 14         s[2] = s3;
 15         s[3] = s4;
 16         WarehouseInformation s5 = new WarehouseInformation();
 17         s[4] = s5;
 18         Scanner sc = new Scanner(System.in);
 19         while (true){
 20             Display_homepage();
 21             int n = sc.nextInt();
 22             switch (n) {
 23                 case 1 -> {Warehouse(s);}
 24                 case 2 -> {Infomod(s);}
 25                 case 3 -> {Outbound(s);}
 26                 case 4 -> {Show(s);return;}
 27                 default -> {System.out.println("该选项不存在");}
 28             }
 29         }
 30     }
 31     public static void Display_homepage(){
 32         System.out.println("""
 33 ***********************************************************
 34 石家庄铁道大学前进22软件开发有限公司
 35 仓库管理系统2022版
 36 ***********************************************************
 37 1、商品入库管理
 38 2、商品信息修改
 39 3、商品出库管理
 40 4、仓库盘点管理
 41 **********************************************************
 42 """);
 43     }
 44     public static void page() {
 45         System.out.println("""
 46 ***********************************************************
 47 石家庄铁道大学前进22软件开发有限公司
 48 仓库管理系统2022版
 49 ***********************************************************
 50 """);
 51     }
 52 
 53     public static void Warehouse(WarehouseInformation[] s){
 54         page();
 55         String no;
 56         String name;
 57         String supplier;
 58         String wtime;
 59         String wnum;
 60         String place;
 61         int num;
 62         Scanner sc = new Scanner(System.in);
 63         while(true) {
 64             System.out.print("商品编号:");
 65             no = sc.next();
 66             System.out.print("商品名称:");
 67             name = sc.next();
 68             System.out.print("供货商信息:");
 69             supplier = sc.next();
 70             System.out.print("入库时间:");
 71             wtime = sc.next();
 72             System.out.print("存放仓库号:");
 73             wnum = sc.next();
 74             System.out.print("存放位置信息:");
 75             place = sc.next();
 76             System.out.print("入库商品数量:");
 77             num = sc.nextInt();
 78             System.out.println("***********************************************************");
 79             if(no.length() == 8 && wtime.length() == 8 && wnum.length() == 3 && place.length() == 8){
 80                 break;
 81             }
 82             System.out.println("录入错误");
 83         }
 84         page();
 85         System.out.println("商品编号:" + no);
 86         System.out.println("商品名称:" + name);
 87         System.out.println("供货商信息:" + supplier);
 88         System.out.println("入库时间:" + wtime);
 89         System.out.println("存放仓库号:" + wnum);
 90         System.out.println("存放位置信息:" + place);
 91         System.out.println("入库商品数量:" + num);
 92         System.out.println("该商品入库操作已完成,是否提交(Y/N)");
 93         String str = sc.next();
 94         if(str.equals("Y")) {
 95             s[4].setItemno(no);
 96             s[4].setItemname(name);
 97             s[4].setSuppliername(supplier);
 98             s[4].setWarehousingtime(wtime);
 99             s[4].setWarehousenumber(wnum);
100             s[4].setWarehouseplace(place);
101             s[4].setItemnumber(num);
102         }
103 
104     } //入库管理
105 
106     public static void Infomod(WarehouseInformation[] s){
107         page();
108         String no;
109         String name;
110         String supplier;
111         String wtime;
112         String wnum;
113         String place;
114         int num;
115         int flag = 0;
116         Scanner sc = new Scanner(System.in);
117         System.out.print("请输入商品编号:");
118         String str = sc.next();
119         System.out.println("**********************************************************");
120         for (int i = 0; i < s.length; i++) {
121             if(s[i].getItemno().equals(str)){
122                 flag = 1;
123                 page();
124                 s[i].show();
125                 System.out.print("请选择需要修改的信息编号:");
126                 int n = sc.nextInt();
127                 switch (n){
128                     case 1->{
129                         System.out.print("请输入修改后的商品编号:");
130                         no = sc.next();
131                         System.out.println("该商品修改操作已完成,是否提交(Y/N)");
132                         String str1 = sc.next();
133                         if(str1.equals("Y")) {
134                             s[i].setItemno(no);
135                         }
136                     }
137                     case 2->{
138                         System.out.print("请输入修改后的商品名称:");
139                         name = sc.next();
140                         System.out.println("该商品修改操作已完成,是否提交(Y/N)");
141                         String str1 = sc.next();
142                         if(str1.equals("Y")) {
143                             s[i].setItemname(name);
144                         }
145                     }
146                     case 3->{
147                         System.out.print("请输入修改后的供货商信息:");
148                         supplier = sc.next();
149                         String str1 = sc.next();
150                         System.out.println("该商品修改操作已完成,是否提交(Y/N)");
151                         if(str1.equals("Y")) {
152                             s[i].setSuppliername(supplier);
153                         }
154                     }
155                     case 4->{
156                         System.out.print("请输入修改后的入库时间:");
157                         wtime = sc.next();
158                         System.out.println("该商品修改操作已完成,是否提交(Y/N)");
159                         String str1 = sc.next();
160                         if(str1.equals("Y")) {
161                             s[i].setWarehousingtime(wtime);
162                         }
163                     }
164                     case 5->{
165                         System.out.print("请输入修改后的存放仓库号:");
166                         wnum = sc.next();
167 
168                         System.out.println("该商品修改操作已完成,是否提交(Y/N)");
169                         String str1 = sc.next();
170                         if(str1.equals("Y")) {
171                             s[i].setWarehousenumber(wnum);
172                         }
173                     }
174                     case 6->{
175                         System.out.print("请输入修改后的存放位置信息:");
176                         place = sc.next();
177                         System.out.println("该商品修改操作已完成,是否提交(Y/N)");
178                         String str1 = sc.next();
179                         if(str1.equals("Y")) {
180                             s[i].setWarehouseplace(place);
181                         }
182                     }
183                     case 7->{
184                         System.out.print("请输入修改后的商品数量:");
185                         num = sc.nextInt();
186                         System.out.println("该商品修改操作已完成,是否提交(Y/N)");
187                         String str1 = sc.next();
188                         if(str1.equals("Y")) {
189                             s[i].setItemnumber(num);
190                         }
191                     }
192                     default -> {
193                         System.out.println("该选项不存在");
194                     }
195                 }
196                 break;
197             }
198         }
199         if(flag == 0){
200             Infomod(s);
201         }
202 
203     } //信息修改
204 
205     public static void Outbound(WarehouseInformation[] s){
206         page();
207         int flag = 0;
208         String stime;
209         int onum;
210         Scanner sc = new Scanner(System.in);
211         System.out.print("请输入商品编号:");
212         String str = sc.next();
213         System.out.println("**********************************************************");
214         for (int i = 0; i < s.length; i++) {
215             if(s[i].getItemno().equals(str)){
216                 flag = 1;
217                 page();
218                 s[i].show();
219                 while(true) {
220                     System.out.print("出库时间:");
221                     stime = sc.next();
222                     System.out.print("出库数量:");
223                     onum = sc.nextInt();
224                     System.out.println("**********************************************************");
225                     if (onum <= (s[i].getItemnumber() - s[i].getOutnumber()) && stime.length() == 8 && (Integer.parseInt(stime) > Integer.parseInt(s[i].getWarehousingtime()))) {
226                         break;
227                     }
228                 }
229                 System.out.println("该商品出库操作已完成,是否提交(Y/N)");
230                 String str1 = sc.next();
231                 if(str1.equals("Y")) {
232                     s[i].setOutnumber(onum);
233                 }
234                 break;
235             }
236         }
237         if(flag == 0){
238             Outbound(s);
239         }
240 
241     } //出库管理
242 
243     public static void Show(WarehouseInformation[] s){
244         page();
245         for (int i = 0; i < s.length; i++) {
246             System.out.println(i + 1 + "、 商品编号: " + s[i].getItemno() + "、商品名称: " + s[i].getItemname() + "、库存数量: " + (s[i].getItemnumber() - s[i].getOutnumber()));
247         }
248         System.out.println("…………………………………………………");
249         System.out.println("**********************************************************");
250     } //仓库盘点
251 }

 

 

标签:开学,String,9.15,System,sc,println,public,考试,out
From: https://www.cnblogs.com/lijianlongCode13/p/17709897.html

相关文章

  • 9.15课堂测试(已在文件发表)
    WarehouseInformation.java: package仓库管理系统;publicclassWarehouseInformation{privateStringitemno;//表示商品编号(有8位数字组成)privateStringitemname;//表示商品名称privateStringsuppliername;//表示供货商名称privateStringwarehou......
  • 开学测试
    publicclassWarehouseInformation{privateStringitemno;privateStringitemname;privateStringsuppliername;privateStringwarehousingtime;privateStringshipmenttime;privateStringwarehousenumber;privateStringwarehouseplac......
  • 开学测试代码
    importjdk.dynalink.beans.StaticClass;importjava.text.DateFormat;importjava.text.ParseException;importjava.text.SimpleDateFormat;importjava.util.Date;importjava.util.Scanner;publicclassWarehouseManagement{staticWarehouseInformation[]wareho......
  • 开学测试修改(9.17)
    packagehomework;publicclassWarehouseInformation{privateStringitemno;privateStringitemname;privateStringsuppliername;privateStringwarehousingtime;privateStringshipmenttime;privateStringwarehousenumber;privateStr......
  • 开学测试题分解步骤
    importjava.util.Scanner;//数据类WarehouseInformationclassWarehouseInformation{   privateStringproductId;   privateStringproductName;   privateStringsupplier;   privateStringentryDate;   privateintwarehouseNumber; ......
  • 开学测试题重写
    packagefile;importjava.util.Scanner;importjava.util.ArrayList;publicclassWarehouseManagement{publicstaticvoidmain(String[]args){ArrayList<WarehouseInformation>x=newArrayList<WarehouseInformation>();while(true......
  • 开学考试
    开学考试代码重写源代码:importjava.util.Scanner;//数据类WarehouseInformationclassWarehouseInformation{   privateStringproductId;   privateStringproductName;   privateStringsupplier;   privateStringentryDate;   privatei......
  • 考试代码
    package拉倒吧;importjava.util.Scanner;publicclassWarehouseInformation{ Stringitemno;//编号 Stringitemname;//商品名称 Stringsuppliername;//供货商名称 Stringwarehousingtime;//入库时间 Stringshipmenttime;//出库时间 Stringwarehousenumber;//仓库编号 St......
  • 开学测试整理
    WarehouseInformation系统的增删改查操作一、实现WarehouseInformation类中的成员变量,赋值函数等;代码如下:publicclassWarehouseInformation{privateStringitemno;//表示商品编号(有8位数字组成)privateStringitemname;//表示商品名称privateStringsup......
  • 9.15 英语精读
    9.15精读 余华 NoverlistYuHua,widelyregardedasaluminaryinmodernChineseliterature,hasaknackforcomdy,particularyininterviews.Thoughneralysixty-four,Yu,whowearshishairshortandspiky,looksrelativelyyoung.Hespeak......