示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("***Prototype Pattern Demo***\n");

            //Base or Original Copy
            BasicCar nano_base = new Nano("Green Nano")
            {
                Price = 100000
            };
            BasicCar ford_base = new Ford("Ford Yellow")
            {
                Price = 500000
            };
            BasicCar bc1;

            //Nano
            bc1       = nano_base.Clone();
            bc1.Price = nano_base.Price + BasicCar.SetPrice();
            Console.WriteLine("Car is: {0}, and it's price is Rs. {1}", bc1.ModelName, bc1.Price);

            //Ford
            bc1       = ford_base.Clone();
            bc1.Price = ford_base.Price + BasicCar.SetPrice();
            Console.WriteLine("Car is: {0}, and it's price is Rs. {1}",
                              bc1.ModelName, bc1.Price);
            Console.ReadLine();
        }
示例#2
0
        static void Main()
        {
            Console.WriteLine("***Prototype Pattern Demo***\n");
            BasicCar nanoBase = new Nano("Green Nano")
            {
                Price = 10000
            };
            BasicCar fordBase = new Ford("Ford Yellow")
            {
                Price = 5000
            };

            BasicCar bc1 = nanoBase.Clone();

            bc1.Price = nanoBase.Price + BasicCar.SetPrice();
            Console.WriteLine("Car is: {0}, and it's price is Rs. {1}", bc1.ModelName, bc1.Price);

            bc1       = fordBase.Clone();
            bc1.Price = fordBase.Price + BasicCar.SetPrice();
            Console.WriteLine("Car is: {0}, and it's price is Rs. {1}", bc1.ModelName, bc1.Price);

            Console.ReadLine();
        }