From c8cf4b8ba8fb12af84f74211e41149a9438b48ce Mon Sep 17 00:00:00 2001 From: adash Date: Fri, 3 Nov 2006 18:10:37 +0000 Subject: [PATCH] Transaction operations available --- Robust/src/Tests/Inventory.java | 91 +++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Robust/src/Tests/Inventory.java 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