static void Main(string[] args)
        {
            // Pato Bravo
            MallardDuck md = new MallardDuck();
            md.Display();
            md.Swim();
            md.Fly();
            md.Quack();
            System.Console.WriteLine("\n");

            // Pato Cabeça-vermelha
            RedHeadDuck rhd = new RedHeadDuck();
            rhd.Display();
            rhd.Swim();
            rhd.Fly();
            rhd.Quack();
            System.Console.WriteLine("\n");

            // Pato de Borracha
            RubberDuck rd = new RubberDuck();
            rhd.Display();
            rhd.Swim();
            rd.Quack(); // Chia invés de grasnar
            System.Console.WriteLine("\n");

            // Pato de Madeira
            DecoyDuck dd = new DecoyDuck();
            dd.Display();
            dd.Swim();
            System.Console.WriteLine("\n");

            System.Console.ReadKey();
        }
示例#2
0
        private static void Main()
        {
            var mallardDuck = new MallardDuck();

            mallardDuck.Display();
            mallardDuck.PerformQuack();
            mallardDuck.Swim();
            mallardDuck.PerformFly();
            Console.WriteLine();

            var redheadDuck = new RedheadDuck();

            redheadDuck.Display();
            redheadDuck.PerformQuack();
            redheadDuck.Swim();
            redheadDuck.PerformFly();
            Console.WriteLine();

            var rubberDuck = new RubberDuck();

            rubberDuck.Display();
            rubberDuck.PerformQuack();
            rubberDuck.Swim();
            rubberDuck.PerformFly();
            Console.WriteLine();

            var decoyDuck = new DecoyDuck();

            decoyDuck.Display();
            decoyDuck.Swim();
            Console.WriteLine();

            Console.Write("Press Enter to exit ...");
            Console.ReadLine();
        }
示例#3
0
        static void Main(string[] args)
        {
            Duck duck = new MallardDuck();

            duck.Display();
            duck.PerformFly();
            duck.PerformQuack();

            Duck model = new DecoyDuck();

            model.Display();
            model.PerformFly();
            model.SetFlyBehavior(new FlyWithWings());
            model.PerformFly();

            Console.ReadLine();
        }
示例#4
0
        static void Main(string[] args)
        {
            // Pato Bravo
            MallardDuck md = new MallardDuck();

            md.Display();
            md.Swim();
            md.Fly();
            md.Quack();
            System.Console.WriteLine("\n");

            // Pato Cabeça-vermelha
            RedHeadDuck rhd = new RedHeadDuck();

            rhd.Display();
            rhd.Swim();
            rhd.Fly();
            rhd.Quack();
            System.Console.WriteLine("\n");

            // Pato de Borracha
            RubberDuck rd = new RubberDuck();

            rhd.Display();
            rhd.Swim();
            rd.Quack(); // Chia invés de grasnar
            System.Console.WriteLine("\n");

            // Pato de Madeira
            DecoyDuck dd = new DecoyDuck();

            dd.Display();
            dd.Swim();
            System.Console.WriteLine("\n");


            System.Console.ReadKey();
        }
示例#5
0
        static void Main(string[] args)
        {
            TestVirtual testVirtual = new TestVirtual();

            Console.WriteLine(testVirtual.resultA);         //using method from overrride
            Console.WriteLine(testVirtual.resultB);         //using method from base class

            Console.WriteLine(testVirtual.add(1, 2));       //using method from overrride
            Console.WriteLine(testVirtual.substract(9, 1)); //using method from base class
            Console.WriteLine();
            //======================================================================================

            SealMethod sealMethod = new SealMethod();

            Console.WriteLine(sealMethod.add(1, 1));
            Console.WriteLine(sealMethod.substract(2, 2));
            Console.WriteLine(sealMethod.multipy(2, 2));
            Console.WriteLine();
            //======================================================================================

            ProtectBase   protectBase   = new ProtectBase();
            TestProtected testProtected = new TestProtected();

            // below will have complier error as "add" method can only be used inside TestProtected
            //Console.WriteLine(TestProtected.add(4, 5));
            Console.WriteLine();
            //======================================================================================

            // below will have compier error - abstract can't be instantiate
            //AbstractBase ab = new AbstractBase();
            TestAbstract testAb = new TestAbstract();

            Console.WriteLine(testAb.add(3, 8));
            Console.WriteLine();
            //======================================================================================

            Console.WriteLine("---- test order system ----");
            Order order = new Order {
                Id = 1, FirstName = "Tan", Email = "*****@*****.**", Price = 10.50M
            };
            OrderingFactory factory = new OrderingFactory();
            IOrderProcess   orderA  = factory.GetOrderSupplier("A");

            orderA.MakeOrder(order);

            Console.WriteLine("");

            IOrderProcess orderB = factory.GetOrderSupplier("B");

            orderB.MakeOrder(order);

            Console.WriteLine("");
            Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++");
            Console.WriteLine("");
            Console.WriteLine(Multi10000(1, 1));
            Console.WriteLine();
            //======================================================================================
            IStore    store    = new Document();
            ICompress compress = new Document();

            store.Read();
            store.Write();
            compress.Compress();
            compress.Decompress();

            using (SimpleClass simple = new SimpleClass())
            {
                Console.WriteLine(simple.returnA());
            }
            Console.WriteLine();
            //======================================================================================


            Duck d1 = new DecoyDuck();

            d1.Display();
            d1.PerformFly();
            d1.PerformQuack();
            Duck d2 = new RubberDuck();

            d2.Display();
            d2.PerformFly();
            d2.PerformQuack();
            Console.WriteLine();
            //======================================================================================

            /*
             * WeatherData weatherData = new WeatherData();
             *
             * CurrentConditionsDisplay currDisplay = new CurrentConditionsDisplay(weatherData);
             * ForecastDisplay foreDisplay = new ForecastDisplay(weatherData);
             *
             * weatherData.setMeasurements(80, 65, 30.4f);
             */

            Console.WriteLine();
            //======================================================================================

            WeatherTracker provider = new WeatherTracker();

            CurrentConditionsDisplay currDisplay = new CurrentConditionsDisplay(provider);
            ForecastDisplay          foreDisplay = new ForecastDisplay(provider);

            provider.UpdateWeather(new WeatherData(80, 65, 30.4f));

            Console.WriteLine();
            //======================================================================================
            BeverageBase beverage = new Decaf();

            Console.WriteLine(beverage.Description
                              + " $" + beverage.cost());

            BeverageBase beverage2 = new DarkRoast();

            beverage2 = new Milk(beverage2);
            beverage2 = new Mocha(beverage2);
            Console.WriteLine(beverage2.Description
                              + " $" + beverage2.cost());


            Console.WriteLine();
            //======================================================================================
            Console.WriteLine(Singleton.Instant.getTest());
            Console.WriteLine(Singleton.Instant.getTest());
            Console.WriteLine(Singleton.Instant.getTest());


            Console.WriteLine();
            //======================================================================================
            Booking booking = new Booking {
                BookingId = 1, SupplierCode = "GTA", FirstName = "Tan", LastName = "Tang", TotalAmount = (decimal)299.99
            };
            ProcessBooking bookingProcess = new ProcessBooking(booking);

            bookingProcess.Initial();
            Console.WriteLine("  Booking State = {0}, Status = {1}", booking.State.ToString(), booking.Status);

            bookingProcess.PreAuthorisation();
            Console.WriteLine("  Booking State = {0}, Status = {1}", booking.State.ToString(), booking.Status);

            bookingProcess.MakeBooking();
            Console.WriteLine("  Booking State = {0}, Status = {1}", booking.State.ToString(), booking.Status);

            bookingProcess.MakePayment();
            Console.WriteLine("  Booking State = {0}, Status = {1}", booking.State.ToString(), booking.Status);

            bookingProcess.FinaliseBooking();
            Console.WriteLine("  Booking State = {0}, Status = {1}", booking.State.ToString(), booking.Status);


            Console.Read();
        }