001package headfirst.factory.pizzaaf;
002
003public abstract class Pizza {
004        String name;
005
006        Dough dough;
007        Sauce sauce;
008        Veggies veggies[];
009        Cheese cheese;
010        Pepperoni pepperoni;
011        Clams clam;
012
013        abstract void prepare();
014
015        void bake() {
016                System.out.println("Bake for 25 minutes at 350");
017        }
018
019        void cut() {
020                System.out.println("Cutting the pizza into diagonal slices");
021        }
022
023        void box() {
024                System.out.println("Place pizza in official PizzaStore box");
025        }
026
027        void setName(String name) {
028                this.name = name;
029        }
030
031        String getName() {
032                return name;
033        }
034
035        public String toString() {
036                StringBuilder result = new StringBuilder();
037                result.append("---- " + name + " ----\n");
038                if (dough != null) {
039                        result.append(dough);
040                        result.append("\n");
041                }
042                if (sauce != null) {
043                        result.append(sauce);
044                        result.append("\n");
045                }
046                if (cheese != null) {
047                        result.append(cheese);
048                        result.append("\n");
049                }
050                if (veggies != null) {
051                        for (int i = 0; i < veggies.length; i++) {
052                                result.append(veggies[i]);
053                                if (i < veggies.length-1) {
054                                        result.append(", ");
055                                }
056                        }
057                        result.append("\n");
058                }
059                if (clam != null) {
060                        result.append(clam);
061                        result.append("\n");
062                }
063                if (pepperoni != null) {
064                        result.append(pepperoni);
065                        result.append("\n");
066                }
067                return result.toString();
068        }
069}