static void Main() { // Create two instances and clone each ConcretePrototype1 p1 = new ConcretePrototype1("I"); ConcretePrototype1 c1 = (ConcretePrototype1)p1.Clone(); Console.WriteLine("Cloned: {0}", c1.Id); ConcretePrototype2 p2 = new ConcretePrototype2("II"); ConcretePrototype2 c2 = (ConcretePrototype2)p2.Clone(); Console.WriteLine("Cloned: {0}", c2.Id); // Wait for user Console.Read(); }
static void Main() { Random rnd = new Random(); int stuid = rnd.Next(1, 15); int stuid2 = rnd.Next(1, 15); int stuid3 = rnd.Next(1, 15); ConcretePrototype1 p1 = new ConcretePrototype1(stuid); ConcretePrototype1 c1 = (ConcretePrototype1)p1.Clone(); Console.WriteLine("Student ID: {0}", c1.Id); ConcretePrototype2 p2 = new ConcretePrototype2(stuid2); ConcretePrototype2 c2 = (ConcretePrototype2)p2.Clone(); Console.WriteLine("Student ID: {0}", c2.Id); ConcretePrototype3 p3 = new ConcretePrototype3(stuid3); ConcretePrototype3 c3 = (ConcretePrototype3)p3.Clone(); Console.WriteLine("Student ID: {0}", c3.Id); Console.ReadKey(); }