001package headfirst.factory.pizzafm;
002
003import java.util.ArrayList;
004
005public abstract class Pizza {
006        String name;
007        String dough;
008        String sauce;
009        ArrayList<String> toppings = new ArrayList<String>();
010
011        void prepare() {
012                System.out.println("Preparing " + name);
013                System.out.println("Tossing dough...");
014                System.out.println("Adding sauce...");
015                System.out.println("Adding toppings: ");
016                for (int i = 0; i < toppings.size(); i++) {
017                        System.out.println("   " + toppings.get(i));
018                }
019        }
020
021        void bake() {
022                System.out.println("Bake for 25 minutes at 350");
023        }
024
025        void cut() {
026                System.out.println("Cutting the pizza into diagonal slices");
027        }
028
029        void box() {
030                System.out.println("Place pizza in official PizzaStore box");
031        }
032
033        public String getName() {
034                return name;
035        }
036
037        public String toString() {
038                StringBuilder display = new StringBuilder();
039                display.append("---- " + name + " ----\n");
040                display.append(dough + "\n");
041                display.append(sauce + "\n");
042                for (int i = 0; i < toppings.size(); i++) {
043                        display.append(toppings.get(i) + "\n");
044                }
045                return display.toString();
046        }
047}
048
049
050