/**
 * Model of a Bakery that sells Cakes
 * @author Suzanne Balik, 19 Feb 2003
 */
public class Bakery {

  private Cake birthdayCake;
  private Cake sheetCake;
  private Cake weddingCake;
  
  public Bakery() {
  
    birthdayCake = new Cake("Birthday Cake", 10, 1);
    sheetCake = new Cake("Sheet Cake", 15, 2);
    weddingCake = new Cake("Wedding Cake", 50, 5);
    
  }
  
  public String buyCake(int type){
  
    switch (type) {
    
      case 1: if (birthdayCake.bake())
                return birthdayCake.getReceipt();
	      else
	        return "Sold out";
	      
      case 2: if (sheetCake.bake())
                return sheetCake.getReceipt();
	      else
	        return "Sold out";
	      
      case 3: if (weddingCake.bake())
                return weddingCake.getReceipt();
              else
	        return "Sold out";
	      
      default: System.out.println("Invalid type: " + type);
    }
    
    return "";
  }
  
  public static void main (String [] args) {

    Bakery bakery = new Bakery();
    
    //Buy a birthday cake
    System.out.println(bakery.buyCake(1));
    
    //Buy a sheet cake
    System.out.println(bakery.buyCake(2));
    
    //Buy a wedding cake
    System.out.println(bakery.buyCake(3));

  }
}

/*PROGRAM OUTPUT:

csc% java Bakery
Birthday Cake  $10.00
Sheet Cake  $15.00
Wedding Cake  $50.00

*/