/** A three topping pizza. */
public class Pizza {
  /** first topping. */
  private Topping topping1;
  /** second topping */
  private Topping topping2;
  /** third topping */
  private Topping topping3;
  /** order number for this pizza order */
  private int orderNumber;
  /** pizza price equals BASE_PRICE plus price of three toppings */
  private double pizzaPrice;
  /** the total number of pizzas ever made */
  private static int numberPizzasMade;
  /** the total amount invoiced for all pizzas */
  private static double totalEarnings;
  /** the base price for a pizza - this is a constant
   *  which is indicated by the word "final".  Note
   *  that constants are all in capital letters with an
   *  underscore separating words.
   */
  private static final double BASE_PRICE = 10.56;
  
  /** 
   * create the boring default pizza
   * containing toppings: mushrooms, pepperoni and green pepper.
   */
  public Pizza() {
    topping1 = new Topping("Mushrooms", 0.50);
    topping2 = new Topping("Pepperoni", 0.50);
    topping3 = new Topping("Green Pepper", 0.50);
    /* we have discovered that we need to initialize the remaining
     * instance variables and class variables exactly the same way
     * for both constructors.  So, rather than have duplicate code
     * in more than one method - (this is bad, because it means it 
     * must be changed in more than one place if something changes.
     * It is hard to maintain), we have created a private "helper"
     * method which we call, and which contains the code that is 
     * common to both methods.
     */
    this.initValues(); //call common code in helper method initValues()
  }
  /**
   * add three toppings of your choice when creating this
   * pizza.  Creates the pizza using the three Topping objects:
   * t1, t2, and t3 which are passed through the input parameters.
   * (see the .hist file for today to see how this is done).
   */ 
  public Pizza(Topping t1, Topping t2, Topping t3) {
     topping1 = t1;
     topping2 = t2;
     topping3 = t3;
     this.initValues();
  }
  /** this helper function initializes the instance and class
   *  variables common to both constructors.
   */
  private void initValues(){
    numberPizzasMade++;
    this.orderNumber = numberPizzasMade;
    this.pizzaPrice = topping1.getPrice() 
          + topping2.getPrice() 
          + topping3.getPrice()
          + BASE_PRICE;
    totalEarnings += this.pizzaPrice;
  }
  /** we create an invoice for our pizza */
  public String invoicePizza() {
    return "Angie's Pizza Parlor - " 
      + "invoice for order number: " + this.orderNumber 
      + "\n Base Price: " + BASE_PRICE 
      + "\nToppings: "
      + "\n   " + this.topping1.getName() + " " +  this.topping1.getPrice()
      + "\n   " + this.topping2.getName() + " "  + this.topping2.getPrice() 
      +  "\n   " + this.topping3.getName() + " "  + this.topping3.getPrice() 
      +  "\nTotal: " + this.pizzaPrice;
  }
  /** return the total amount earned from making pizzas */
  public static double getEarnings() {
    return totalEarnings;
  }
  
  public int getOrderNum() {
    return this.orderNumber;
  }
  
}

    
    

