示例#1
0
        public void getFordPriceTest()
        {
            decimal price = 0;

            // Test default car price
            Car ford = new FordFocus();

            price = ford.GetPrice();

            Assert.AreEqual((decimal)9000.5, price);

            // Test car price with AirCo
            Car airco = new AirCo(ford);

            price = airco.GetPrice();

            Assert.AreEqual((decimal)9150.5, price);

            // Test car price with 2 or more accessories
            Car gps = new GPS(airco);

            price = gps.GetPrice();

            Assert.AreEqual((decimal)9250.75, price);
        }
示例#2
0
        static void Main(string[] args)
        {
            IVendible kangoo = new RenaultKangoo();

            kangoo = new CubreCarter(kangoo);

            Console.WriteLine(kangoo.GetDescripcion());
            Console.WriteLine("Su precio es ${0}", kangoo.GetPrecio());
            Console.WriteLine();
            Console.WriteLine("***********************************************************");

            IVendible prisma = new ChevroletPrisma();

            prisma = new LlantasAleacion(prisma);
            prisma = new CubreCarter(prisma);

            Console.WriteLine(prisma.GetDescripcion());
            Console.WriteLine("Su precio es ${0}", prisma.GetPrecio());
            Console.WriteLine();
            Console.WriteLine("***********************************************************");

            prisma = new AsientoCuero(prisma);
            prisma = new Polarizado(prisma);

            Console.WriteLine(prisma.GetDescripcion());
            Console.WriteLine("Su precio es ${0}", prisma.GetPrecio());
            Console.WriteLine();
            Console.WriteLine("***********************************************************");

            IVendible focus = new FordFocus();

            focus = new LlantasAleacion(focus);
            focus = new AsientoCuero(focus);
            focus = new Polarizado(focus);
            focus = new CajaAutomatica(focus);

            Console.WriteLine(focus.GetDescripcion());
            Console.WriteLine("Su precio es ${0}", focus.GetPrecio());
            Console.WriteLine();
            Console.WriteLine("***********************************************************");

            Console.ReadLine();
        }