Beispiel #1
0
        public static void Execute()
        {
            ConsoleExtension.WriteSeparator("Air traffic control example");

            var airTraficControl = new FrankfurtAirTrafficControl();

            // Register flights to air trafic control
            var flight1 = new AirbusA320("ARB320", 28000, airTraficControl);
            var flight2 = new Boeing737("BNG737", 29000, airTraficControl);
            var flight3 = new Boeing777("BNG777", 35000, airTraficControl);

            Console.WriteLine($"\nChanging altitude for {flight1.CallSign}...");
            flight1.Altitude += 1000;
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            // Mediator patterns defines an object that encapsulates how a set of objects interact between themselves.
            // Communication between objects is encapsulated in a mediator object. Objects do not communicate directly with each other, but through the mediator.
            var airbusGaruda    = new AirbusA320("Garuda Indonesia", 10000);
            var airbusThai      = new AirbusA320("Thai Airways", 25000);
            var boeingSingapore = new Boeing777("Singapore Airlines", 35000);

            var trafficController = new AirTrafficController();

            trafficController.Register(airbusGaruda);
            trafficController.Register(airbusThai);
            trafficController.Register(boeingSingapore);

            airbusThai.SendMessage(trafficController, "Sawasdee krab");
            airbusGaruda.SendMessage(trafficController, "Apa kabar");

            Console.WriteLine("======================================================");
            Console.WriteLine("Note: Singapore Airlines does not sending any messages");
            Console.WriteLine("======================================================");
            Console.ReadKey();
        }