
/**
 * class Items keeps track of the number and name of an item in Inventory
 * 
 * Today:
 * 1) Static instance variables
 * 2) Inventory class 
 * 
 * @author Kathryn
 * @version February 2007
 */
public class Items
{
    // Add static instance variable to track total inventory accross all items
    // instance variables, name and an amount
    static private int totalAmounts = 0;
    private int amount;
    private String name;

    /**
     * Constructor for objects of class Items
     */
    public Items()
    {
        // initialise instance variables
        amount = 0;
        name = null;
    }
    public Items(String n, int a) {
        if (a >= 0) {
            totalAmounts+=a;
            amount = a;
        } else {
            amount = 0;
        }
        name = n;
    }

    public Items(String n) {
        amount = 0;
        name = n;
    }
    
    public String getName() {
        return this.name;
    }
    public void setName(String newName) {
        name = newName;
    }
    public int getAmount() {
        return this.amount;
    }
    public void setAmount(int newAmount) {
        if (newAmount < 0) {
            // Error handling
        } else {
            totalAmounts += newAmount - amount;
            amount = newAmount;
        }
    }
    public String toString() {
        String objectState = amount + " of " + getName() + ". " + totalAmounts + ": Total over all Items";
        return objectState;
    }
    
//   public static void main (String[] args) {
//        Items red = new Items("Red Delicious", 50);
//       System.out.println (red.toString());
        
//    }
       


}
