From: adash Date: Fri, 3 Nov 2006 18:10:37 +0000 (+0000) Subject: Transaction operations available X-Git-Tag: preEdgeChange~769 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c8cf4b8ba8fb12af84f74211e41149a9438b48ce;p=IRC.git Transaction operations available --- diff --git a/Robust/src/Tests/Inventory.java b/Robust/src/Tests/Inventory.java new file mode 100644 index 00000000..94d79e63 --- /dev/null +++ b/Robust/src/Tests/Inventory.java @@ -0,0 +1,91 @@ +public class Inventory { + // Inventory flags + flag TransInitialize; + + // Transaction variables + int numitems; + int current;//keeps track of current position + int totalvalue; + + // Item properties + String item_name[]; + int item_quantity[]; + int item_price[]; + + // Constructor + public Inventory(){ + current = 0; + } + + public Inventory(int howmany) { + numitems = howmany;// howmany keeps track of the number of items + // in the inventory + current = 0; + item_name = new String[howmany]; + item_quantity = new int [howmany]; + item_price = new int [howmany]; + for (int i = 0; i < howmany; i++) { + item_name[i] = ""; + item_quantity[i] = 0; + item_price[i] = 0; + } + } + + // Add item to a list of inventory + public int additem(String name, int quantity, int price){ + //check current value + if(current>=numitems){ + System.printString("Cannot add any further items"); + return -1; + } + // Search thru existing items + for(int i=0; i