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(); }
public void setPrototype(Ad ad) { this.ad = ad; }
public AdFactory(Ad ad) { setPrototype(ad); }
public Object copy() { Ad copy = new Ad(name, timeLong); return(copy); }