Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.WriteLine("Code running: Project Version " + RoadVehicle.projectVersion);

            RoadVehicle v1 = new RoadVehicle(123456);
            RoadVehicle v2 = new RoadVehicle(246810, 3, 1);

            if ((v1 is null) || (v2 is null))
            {
                Console.WriteLine("Error: object is null.");
                return;
            }

            Console.WriteLine(v1.Description);
            Console.WriteLine(v2.Description);

            Console.ReadLine();

            Car PrimaryCar = new Car(EngineSerialNumber: 13579);

            PrimaryCar.HasTowBar = true;
            Console.WriteLine(PrimaryCar.Description);

            Console.ReadLine();
        }
Exemplo n.º 2
0
        public static void Main()
        {
            //get everything
            var cessna     = new Cessna();
            var hovercraft = new HoverCraft();
            var jetski     = new JetSki();
            var boat       = new Boat();
            var motorcycle = new Motorcycle();
            var car        = new Car();



            // Build a collection of all vehicles that fly
            var FlyingVehicles = new List <IFly> {
                cessna
            };

            FlyingVehicles.Add(cessna);
            FlyingVehicles.Add(hovercraft);

            foreach (var FlyingVehicle in FlyingVehicles)
            {
                FlyingVehicle.Fly();
            }

            // Build a collection of all vehicles that operate on roads
            var RoadVehicles = new List <ILand> {
                motorcycle
            };

            RoadVehicles.Add(motorcycle);
            RoadVehicles.Add(car);

            // With a single `foreach`, have each road vehicle Drive()
            foreach (var RoadVehicle in RoadVehicles)
            {
                RoadVehicle.Drive();
            }


            // Build a collection of all vehicles that operate on water

            var WaterVehicles = new List <IWater> {
                jetski, boat
            };

            WaterVehicles.Add(jetski);
            WaterVehicles.Add(boat);

            // With a single `foreach`, have each water vehicle Drive()
            foreach (var WaterVehicle in WaterVehicles)
            {
                WaterVehicle.Drive();
            }
            Console.Read();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.WriteLine("Code running: Project version " + RoadVehicle.ProjectVersion);

            RoadVehicle v1 = new RoadVehicle(EngineSerialNumber: 12345);

            Console.WriteLine(v1.Description);

            RoadVehicle v2 = new RoadVehicle(EngineSerialNumber: 2468);

            Console.WriteLine(v2.Description);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.WriteLine("Code running: Project version " + RoadVehicle.ProjectVersion);

            RoadVehicle v1 = new RoadVehicle(EngineSerialNumber: 12345);

            Console.WriteLine(v1.Description);

            RoadVehicle v2 = new RoadVehicle(EngineSerialNumber: 2468);

            Console.WriteLine(v1.Description);

            Car PrimaryCar = new Car(EngineSerialNumber: 13579);

            PrimaryCar.HasTowBar = true;
            Console.WriteLine(PrimaryCar.Description);
        }