Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Airplanes controller: \n");
            Console.Beep();

            var ABC123 = new PeoplePlane("ABC123", 50, 0, false, 350);
            var DDD888 = new PeoplePlane("DDD888", 35, 0, false, 450);
            var SSS777 = new PeoplePlane("SSS777", 70, 0, false, 250);

            //Operations on ABC123:
            Console.WriteLine($"Operations on {ABC123.PlaneId}: \n");
            Console.Beep(3000, 300);
            ABC123.LoadPassengers(43);
            ABC123.TakeOff();
            ABC123.Land();
            ABC123.UnloadPassengers(43);


            //Operations on DDD888
            Console.WriteLine($"Operations on {DDD888.PlaneId}: \n");
            DDD888.LoadPassengers(23);
            DDD888.TakeOff();
            DDD888.Land();
            DDD888.UnloadPassengers(23);

            //Creating airport with airplanes
            var eindhovenAirport = new Airport("Eindhoven", ABC123, DDD888, SSS777);

            //Operations on the airport:
            eindhovenAirport.ListAirplanes();
            eindhovenAirport.RequestPlaneDetails();
            eindhovenAirport.LoadPassengersInto(ABC123, 55);

            //Instantiating cargo planes
            var FF2134 = new CargoPlane("FF2134", false, 0);
            var PLA166 = new CargoPlane("PLA166", false, 0);

            //Adding the two cargo planes to the airport Eindhoven:
            eindhovenAirport.AddCargoPlane(FF2134);
            eindhovenAirport.AddCargoPlane(PLA166);

            //Operations on the cargo planes
            eindhovenAirport.LoadCargoInto(FF2134, 17);

            //Calling the overriden ToString method
            Console.WriteLine(FF2134);
            Console.WriteLine(PLA166);

            Console.WriteLine(ABC123);
            Console.WriteLine(DDD888);
            Console.WriteLine(SSS777);

            Console.Beep();

            //The spaceship
            var SPACE123 = new SpacePlane("SPACE123", false);

            SPACE123.LoadMissles();
            SPACE123.StartStarterMotor();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            /*create an airport which has 3 people plane,
             * 2 cargo plane and 1 space plane*/
            var airport1 = new Airport("Eindhoven");

            //list all the airplanes of the airport
            airport1.ShowAirplanes();

            //request airplanes and take some actions with them
            try
            {
                PeoplePlane airplane1 = (PeoplePlane)airport1.RequestPlane("ABC124");
                airplane1.Load(133);
                airplane1.TakeOff();
                airplane1.Load(5);
                airplane1.Land();
                airplane1.Unload();
                airport1.ShowAvailableAirplanes();
            }
            catch (NullReferenceException ex)
            {
                Console.WriteLine(ex);
            }
            try
            {
                CargoPlane airplane2 = (CargoPlane)airport1.RequestPlane("FF2134");
                airplane2.Load(25);
                airplane2.TakeOff();
                airplane2.Unload();
                airplane2.Land();
                airplane2.Unload();
            }
            catch (NullReferenceException ex)
            {
                Console.WriteLine(ex);
            }
            try
            {
                SpacePlane spaceAirplane = (SpacePlane)airport1.RequestPlane("SPC777");
                spaceAirplane.StartMotor();
                spaceAirplane.TakeOff();
                spaceAirplane.TakeOverMissile(5);
            }
            catch (NullReferenceException ex)
            {
                Console.WriteLine(ex);
            }
        }