FileDocCategorySizeDatePackage
BurritoInventory.javaAPI DocExample1335Tue Jan 25 10:45:14 GMT 2000None

BurritoInventory

public class BurritoInventory extends Object

Fields Summary
private static BurritoInventory
instance
private int
cheese
private int
rice
private int
beans
private int
chicken
Constructors Summary
private BurritoInventory()

 
Methods Summary
public voidaddBeans(int added)

 beans += added; 
public voidaddCheese(int added)


  // Add to the inventory
       cheese += added; 
public voidaddChicken(int added)

 chicken += added; 
public voidaddRice(int added)

 rice += added; 
public static BurritoInventorygetInstance()


  // Make the static instance publicly available
       return instance; 
public synchronized booleanmakeBurrito()

    // Burritos require one serving of each item
    if (cheese > 0 && rice > 0 && beans > 0 && chicken > 0) {
      cheese--; rice--; beans--; chicken--;
      return true;  // can make the burrito
    }
    else {
      // Could order more ingredients
      return false;  // cannot make the burrito
    }