⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inventory.java.java

📁 java货物进销管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
displayInventory(); 
writeNewInventory(); 
} 
/* 
* order staffs according to the content read from file 
*/ 
public void order(int identify, int quality, int custom) { 
try { 
String fileNameShipping, fileNameError; 
fileNameShipping = "src/experiment3/Shipping.dat"; 
fileNameError = "src/experiment3/Error.dat"; 
PrintWriter outShipping, outError; 
FileOutputStream fosShipping, fosError; 
fosShipping = new FileOutputStream(fileNameShipping,true); 
BufferedOutputStream burShipping = new BufferedOutputStream( 
fosShipping); 
outShipping = new PrintWriter(burShipping,true); 
fosError = new FileOutputStream(fileNameError, true); 
BufferedOutputStream burError = new BufferedOutputStream(fosError); 
outError = new PrintWriter(burError, true); 
for (int i = 0; i < aIdentify.size(); i++) { 
String item = String.valueOf(aIdentify.elementAt(i)); 
String number = String.valueOf(aQuality.elementAt(i)); 
int m = Integer.parseInt(item); 
int n = Integer.parseInt(number); 
if (identify == m) { 
if (n >= quality) { 
outShipping.println(custom + "\t" + identify + "\t" 
+ quality + "\t"); 
aquality.ElementAt(n - quality, i); 
} else { 
System.out 
.println("ErrorOccurs When Order More Quality For \"" 
+ identify 
+ " \"!\nThere Is Not Enough Quality! Can Not Order More!\n"); 
outError.println(custom + "\t" + identify + "\t" 
+ quality + "\t"); 
} 
} 
} 
} catch (FileNotFoundException e) { 
e.printStackTrace(); 
} catch (IOException e) { 
e.printStackTrace(); 
} 
} 
/* 
* order staffs according to the content read from file 
*/ 
public void order() { 
for (int i = 0; i < this.order.size(); i++) { 
String tmp = String.valueOf(this.order.elementAt(i)); 
StringTokenizer st = new StringTokenizer(tmp); 
while (st.hasMoreTokens()) { 
this.orderDescription.add(st.nextToken()); 
this.orderIdentify.add(st.nextToken()); 
this.orderQuality.add(st.nextToken()); 
this.orderSupplier.add(st.nextToken()); 
} 
} 
for (int i = 0; i < this.order.size(); i++) 
for (int j = i + 1; j < this.order.size(); j++) 
if (Integer.parseInt(String.valueOf(this.orderIdentify 
.elementAt(i))) == Integer.parseInt(String 
.valueOf(this.orderIdentify.elementAt(j)))) { 
if (Integer.parseInt(String.valueOf(this.orderQuality 
.elementAt(i))) > Integer.parseInt(String 
.valueOf(this.orderQuality.elementAt(j)))) { 
int tmp1 = Integer.parseInt(String 
.valueOf(this.orderQuality.elementAt(i))); 
this.orderQuality.setElementAt(this.orderQuality 
.elementAt(j), i); 
this.orderQuality.a.ElementAt(tmp1, j); 
int tmp2 = Integer.parseInt(String 
.valueOf(this.orderSupplier.elementAt(i))); 
this.orderSupplier.setElementAt(this.orderSupplier 
.elementAt(j), i); 
this.orderSupplier.a.ElementAt(tmp2, j); 
} 
} 
for (int i = 0; i < this.order.size(); i++) for (int j = i + 1; j < 
this.order.size(); j++) if 
(Integer.parseInt(String.valueOf(this.orderIdentify .elementAt(i))) ==  Integer.parseInt(String .valueOf(this.orderIdentify.elementAt(j)))) { 
if (Integer.parseInt(String.valueOf(this.orderQuality .elementAt(i))) ==  Integer.parseInt(String .valueOf(this.orderQuality.elementAt(j)))) { 
this.orderQuality.setElementAt(Integer.parseInt(String 
.valueOf(this.orderQuality.elementAt(i))) +  Integer.parseInt(String.valueOf( this.orderQuality.elementAt(j))), 
i); this.orderDescription.removeElementAt(j); 
this.orderIdentify.removeElementAt(j); 
this.orderQuality.removeElementAt(j); 
this.orderSupplier.removeElementAt(j); } } 
for (int i = 0; i < this.orderDescription.size(); i++) { 
int orderId = Integer.parseInt(String.valueOf(this.orderIdentify 
.elementAt(i))); 
int orderQua = Integer.parseInt(String.valueOf(this.orderQuality 
.elementAt(i))); 
int orderSup = Integer.parseInt(String.valueOf(this.orderSupplier 
.elementAt(i))); 
order(orderId, orderQua, orderSup); 
} 
} 
/* 
 *reive staffs according to the content read from file 
*/ 
public void receive(int identify, int quality) { 
for (int i = 0; i < aIdentify.size(); i++) { 
String item = String.valueOf(aIdentify.elementAt(i)); 
String number = String.valueOf(aQuality.elementAt(i)); 
int m = Integer.parseInt(item); 
int n = Integer.parseInt(number); 
if (m == identify) { 
a.set(i, n + quality); 
} 
} 
} 
/* 
* reive staffs according to the content read from file 
*/ 
public void receive() { 
for (int i = 0; i < this.receive.size(); i++) { 
String tmp = String.valueOf(this.receive.elementAt(i)); 
StringTokenizer st = new StringTokenizer(tmp); 
while (st.hasMoreTokens()) { 
String receive = st.nextToken(); 
int identify = Integer.parseInt(st.nextToken()); 
int quality = Integer.parseInt(st.nextToken()); 
receive(identify, quality); 
} 
} 
} 
/* 
* add new item to data 
*/ 
public void addNewItem(int aIdentify, int aSupplier, String aDescription) { 
this.a.add(aIdentify); 
this.a.add(0); 
this.a.add(aSupplier); 
this.a.add(aDescription); 
for (int i = 0; i < this.aIdentify.size() - 1; i++) 
for (int j = i + 1; j < this.aIdentify.size(); j++) 
if (Integer.parseInt(String 
.valueOf(this.aIdentify.elementAt(i))) > Integer 
.parseInt(String.valueOf(this.aIdentify.elementAt(j)))) { 
int tmp1 = Integer.parseInt(String.valueOf(this.aIdentify 
.elementAt(i))); 
this.aIdentify.setElementAt(this.aIdentify.elementAt(j), i); 
this.a.ElementAt(tmp1, j); 
int tmp2 = Integer.parseInt(String.valueOf(this.aQuality 
.elementAt(i))); 
this.aQuality.setElementAt(this.aQuality.elementAt(j), i); 
this.a.ElementAt(tmp2, j); 
int tmp3 = Integer.parseInt(String.valueOf(this.aSupplier 
.elementAt(i))); 
this.aSupplier.setElementAt(this.aSupplier.elementAt(j), i); 
this.a.ElementAt(tmp3, j); 
String tmp4 = String 
.valueOf(this.aDescription.elementAt(i)); 
this.aDescription.setElementAt(this.aDescription 
.elementAt(j), i); 
this.aDescription.setElementAt(tmp4, j); 
} 
} 
/* 
* add new item to data 
*/ 
public void addNewItem() { 
for (int i = 0; i < this.addNewItem.size(); i++) { 
String tmp = String.valueOf(this.addNewItem.elementAt(i)); 
StringTokenizer st = new StringTokenizer(tmp); 
while (st.hasMoreTokens()) { 
String addNewItem = st.nextToken(); 
int identify = Integer.parseInt(st.nextToken()); 
int supplier = Integer.parseInt(st.nextToken()); 
String description = st.nextToken(); 
addNewItem(identify, supplier, description); 
} 
} 
for (int i = 0; i < this.addNewItem.size(); i++) { 
} 
} 
/* 
* delete data after reading data from file 
*/ 
public void delete(int identify) { 
try { 
String fileNameError; 
fileNameError = "src/experiment3/Error.dat"; 
PrintWriter outError; 
FileOutputStream fosError; 
fosError = new FileOutputStream(fileNameError, true); 
BufferedOutputStream burError = new BufferedOutputStream(fosError); 
outError = new PrintWriter(burError, true); 
for (int i = 0; i < aIdentify.size(); i++) { 
String item = String.valueOf(aIdentify.elementAt(i)); 
String number = String.valueOf(aQuality.elementAt(i)); 
int m = Integer.parseInt(item); 
int quality = Integer.parseInt(number); 
if (m == identify) 
if (quality == 0) { 
System.out.println("Deleted item " + identify + "!\n"); 
aIdentify.removeElementAt(i); 
aQuality.removeElementAt(i); 
aSupplier.removeElementAt(i); 
aDescription.removeElementAt(i); 
} else { 
System.out 
.println("The quality of this item \"" 
+ identify 
+ "\" you want to " 
+ "delete is not zero! \nSorry! You can not delete it!\n"); 
outError.println("0\t" + identify + "\t" + quality 
+ "\t"); 
} 
} 
} catch (FileNotFoundException e) { 
e.printStackTrace(); 
} catch (IOException e) { 
e.printStackTrace(); 
} 
} 

/* 
* delete data after reading data from file 
*/ 

public void delete() { 
for (int i = 0; i < this.delete.size(); i++) { 
String tmp = String.valueOf(this.delete.elementAt(i)); 
StringTokenizer st = new StringTokenizer(tmp); 
while (st.hasMoreTokens()) { 
String delete = st.nextToken(); 
int identify = Integer.parseInt(st.nextToken()); 
delete(identify); 
} 
} 
} 
/* 
* the main method; 
*/ 
public static void main(String[] args) { 
Inventory staff = new Inventory(); 
staff.dealWithTransactions(); 
} 
} 

 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -