public static void main(String[] args) { PizzaStore nyStore = new NYPizzaStore(); PizzaStore chicagoStore = new ChicagoPizzaStore(); Pizza pizza = nyStore.orderPizza("cheese"); System.out.println("Ethan ordered a " + pizza.getName() + "\n"); pizza = chicagoStore.orderPizza("cheese"); System.out.println("Joel ordered a " + pizza.getName() + "\n"); pizza = nyStore.orderPizza("potato"); System.out.println("Ethan ordered a " + pizza.getName() + "\n"); pizza = chicagoStore.orderPizza("potato"); System.out.println("Joel ordered a " + pizza.getName() + "\n"); }
public Pizza orderPizza(String type) { Pizza pizza = createPizza(type); System.out.println("--- Making a " + pizza.getName() + " ---"); pizza.prepare(); pizza.bake(); pizza.cut(); pizza.box(); return pizza; }
public static void main(String[] args) { Pizza myPizza = new Pizza("Pepperoni", 8, 10.50, 10); System.out.printf( "Your %s pizza has %.2f square inches " + " per slice.\n", myPizza.getName(), myPizza.areaPerSlice()); System.out.printf( "One slice costs $%.2f, which comes" + " to $%.3f per square inch.\n", myPizza.costPerSlice(), myPizza.costPerSquareInch()); Pizza pineapple = new Pizza("Pineapple & Pepper", 10, 11.95, 8); System.out.printf( "Your %s pizza has %.2f square inches " + " per slice.\n", myPizza.getName(), myPizza.areaPerSlice()); System.out.printf( "One slice costs $%.2f, which comes" + " to $%.3f per square inch.\n", myPizza.costPerSlice(), myPizza.costPerSquareInch()); }