コード例 #1
0
        static void Main(string[] args)
        {
            Ad original = new Ad("Jacobs", 30);

            Console.WriteLine(original.toString());

            Ad copy = (Ad)original.copy();

            Console.WriteLine(copy.toString());

            AdFactory factory = new AdFactory(copy);
            Ad        a1      = factory.makeCopy();

            Console.WriteLine(a1.toString());

            factory.setPrototype(new Ad("Nescafe", 180));
            Ad a2 = factory.makeCopy();

            Console.WriteLine(a2.toString());

            Console.ReadKey();
        }
コード例 #2
0
 public void setPrototype(Ad ad)
 {
     this.ad = ad;
 }
コード例 #3
0
 public AdFactory(Ad ad)
 {
     setPrototype(ad);
 }
コード例 #4
0
        public Object copy()
        {
            Ad copy = new Ad(name, timeLong);

            return(copy);
        }