001package headfirst.factory.pizzas;
002
003import java.util.ArrayList;
004
005abstract public class Pizza {
006        String name;
007        String dough;
008        String sauce;
009        ArrayList<String> toppings = new ArrayList<String>();
010
011        public String getName() {
012                return name;
013        }
014
015        public void prepare() {
016                System.out.println("Preparing " + name);
017        }
018
019        public void bake() {
020                System.out.println("Baking " + name);
021        }
022
023        public void cut() {
024                System.out.println("Cutting " + name);
025        }
026
027        public void box() {
028                System.out.println("Boxing " + name);
029        }
030
031        public String toString() {
032                // code to display pizza name and ingredients
033                StringBuilder display = new StringBuilder();
034                display.append("---- " + name + " ----\n");
035                display.append(dough + "\n");
036                display.append(sauce + "\n");
037                for (int i = 0; i < toppings.size(); i++) {
038                        display.append(toppings.get(i) + "\n");
039                }
040                return display.toString();
041        }
042}
043