示例#1
0
        public static void Main(string[] args)
        {
            Decoration d1 = new Decoration("Hello World!");

            Cake c1 = new Cake(4, 300.0, d1);
            Cake c2 = new Cake(200.0);

            System.Console.WriteLine("c1 " + c1.NumSlices);
            System.Console.WriteLine("c2 " + c2.NumSlices);
            System.Console.WriteLine("c1 - decoration is " + c1.Deco.Shape);
        }
示例#2
0
 public Cake(double sugar)
 {
     this.Sugar     = sugar;
     this.NumSlices = 16;
     this.Deco      = new Decoration("Star");
 }
示例#3
0
 // ==== constructor ====
 public Cake(int numslices, double sugar, Decoration deco)
 {
     this.NumSlices = numslices;
     this.Sugar     = sugar;
     this.Deco      = deco;
 }