public class DoughnutShop
public static void Main()
if (!Char.IsDigit(input = Console.ReadLine()[0]) || (choice = input - '0') < 1 || choice > 6)
Console.WriteLine("Please choose from 1 - 6 only. {0}", choice);
PlainDoughnut pdObject = null;
case 1: pdObject = new PlainDoughnut();
case 2: pdObject = new Menu.PlainChoco();
case 3: pdObject = new Menu.PlainStrawberry();
case 4: pdObject = new Menu.ChocoCrunch();
case 5: pdObject = new Menu.StrawberrySprinkles();
case 6: pdObject = new Menu.CinnamonCrunch();
Console.WriteLine("The total amount is {0}", pdObject.ComputeCost());
public static void displayMenu()
Console.WriteLine("Order a Dozen piece of Doughnut; choose a flavor:");
Console.WriteLine("[1] Plain Doughnut");
Console.WriteLine("[2] Plain Choco");
Console.WriteLine("[3] Plain Strawberry");
Console.WriteLine("[4] Choco Crunch");
Console.WriteLine("[5] Strawberry Sprinkles");
Console.WriteLine("[6] Cinnamon Crunch");
public class PlainChoco : PlainDoughnut
Console.WriteLine("PlainChoco");
Console.WriteLine("Toppings: ");
toppings[tCount++] = new ChocoGlaze();
public class PlainStrawberry : PlainDoughnut
Console.WriteLine("PlainStrawberry");
Console.WriteLine("Toppings: ");
toppings[tCount++] = new StrawberryGlaze();
public class ChocoCrunch : PlainChoco
Console.WriteLine("ChocoCrunch");
Console.WriteLine("Toppings: ");
toppings[tCount++] = new PeanutCrunch();
public class StrawberrySprinkles : PlainStrawberry
public StrawberrySprinkles()
Console.WriteLine("StrawberrySprinkles");
Console.WriteLine("Toppings: ");
toppings[tCount++] = new CandySprinkles();
public class CinnamonCrunch : PlainDoughnut
Console.WriteLine("CinnamonCrunch");
Console.WriteLine("Toppings: ");
toppings[tCount++] = new CinnamonDust();
toppings[tCount++] = new PeanutCrunch();
public class PlainDoughnut
protected Topping[] toppings = new Topping[5];
Console.WriteLine("PlainDoughnut");
public double ComputeCost()
foreach (Topping t in toppings)
if (t != null) cost += t.cost;
public class ChocoGlaze : Topping
Console.WriteLine("...ChocoGlaze");
public class StrawberryGlaze : Topping
Console.WriteLine("...StrawberryGlaze");
public class CandySprinkles : Topping
Console.WriteLine("...CandySprinkles");
public class PeanutCrunch : Topping
Console.WriteLine("...PeanutCrunch");
public class CinnamonDust : Topping
Console.WriteLine("...CinnamonDust");