public object Clone() { Console.WriteLine("Clone repertuar"); Repertuar repertuar = new Repertuar(this.month, this.performancesAmount, this.performances); return(repertuar); }
public Repertuar(Repertuar repertuar) { Console.WriteLine("Copy constr"); this.monthProperty = repertuar.monthProperty; this.performances = repertuar.performances; this.performancesAmount = repertuar.performancesAmount; }
public static void Main(string[] args) { Trupa trupa1 = new Trupa("FirstTrupa", 5, 500.0); Building building1 = new Building("Building1", "Adress1", 400.0, 50); Performance performance1 = new Performance("Performance1", Category.OPERA, building1, trupa1, System.DateTime.Now, false); Performance performance2 = new Performance("Performance2", Category.DRAMA, building1, trupa1, System.DateTime.Now, true); Performance performance3 = new Performance("Performance3", Category.OPERA, building1, trupa1, System.DateTime.Now, false); Performance[] performances1 = { performance1, performance2 }; Performance[] performances2 = { performance1, performance3 }; Repertuar repertuar1 = new Repertuar("may", 2, performances1); Repertuar repertuar2 = new Repertuar("june", 2, performances2); repertuar1.info(); repertuar2.info(); Repertuar repertuar3 = (Repertuar)repertuar2.Clone(); Console.WriteLine(repertuar1); Console.WriteLine(repertuar1[0]); BaseNonVirtual baseNonVirtual = new BaseNonVirtual(); DerrivedNonVirtual derrivedNonVirtual = new DerrivedNonVirtual(); BaseNonVirtual baseNonVirtualHref = null; baseNonVirtualHref = baseNonVirtual; baseNonVirtualHref.method(); // output: BaseNonVirtual baseNonVirtualHref = derrivedNonVirtual; baseNonVirtualHref.method(); // output: BaseNonVirtual BaseVirtual baseVirtual = new BaseVirtual(); DerrivedVirtual derrivedVirtual = new DerrivedVirtual(); BaseVirtual baseVirtualHref = null; baseVirtualHref = baseVirtual; baseVirtualHref.method(); // output: BaseVirtual baseVirtualHref = derrivedVirtual; baseVirtualHref.method(); // output: DerrivedVirtual }