Beispiel #1
0
 public void Update(Item item) {
   int i, sta = 0;
   for (i = 0; i < list.size(); i++)
     if (list.get(i).getNumber() == item.getNumber()) {
       sta = 1;
       break;
     }
   if (sta == 0) System.out.println("仓库中没有此编号商品");
   else {
     list.get(i).setStock(item.getStock());
     System.out.println("已更新仓库");
   }
 }
Beispiel #2
0
 // 读写的方法
 public void Save() {
   try {
     file.delete();
     FileWriter writer = new FileWriter(file);
     for (Item i : list)
       writer.write(
           i.getNumber()
               + ";"
               + i.getCategory()
               + ";"
               + i.getName()
               + ";"
               + i.getModel()
               + ";"
               + i.getStock()
               + "\n");
     writer.close();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Beispiel #3
0
 public void show() {
   Collections.sort(
       list,
       new Comparator<Item>() {
         public int compare(Item i1, Item i2) {
           if (i1.getNumber() > i2.getNumber()) return 1;
           else return -1;
         }
       });
   for (Item i : list)
     System.out.println(
         i.getNumber()
             + ";"
             + i.getCategory()
             + ";"
             + i.getName()
             + ";"
             + i.getModel()
             + ";"
             + i.getStock());
 }