public override CakeBase Copy() { CakeBase cb = new Strawberry(name, NextBase); if (NextBase != null) { ((ToppingBase)cb).NextBase = NextBase.Copy(); } return(cb); }
static void Main(string[] args) { Icecream ice = new Icecream("甜筒"); OreoCookies oreo = new OreoCookies(); Cashews cashew = new Cashews(); Strawberry strawberry = new Strawberry(); oreo.Decorator(ice); cashew.Decorator(oreo); strawberry.Decorator(cashew); Console.WriteLine("The total is\t{0:C}", strawberry.Cost()); Console.ReadKey(); }