static void Main(string[] args)
        {
            /*
             * Todo follow all comments!! 
             */

            #region Vehicles

            /*
             * Done - Create an abstract class called Vehicle
             * Done - The vehicle class shall have three string properties Year, Make, and Model
             * Done - Set the defaults to something generic in the Vehicle class
             * Done - Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Done - Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */



            /* 
             * Done = Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Done - Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Done - Provide the implementations for the abstract methods
             * Done - Only in the Motorcycle class will you override the virtual drive method
            */

            // Done - Create a list of Vehicle called vehicles

            var vehicles = new List<Vehicle>();

            /*
             * Done - Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */

            var focus = new Car() { hasTrunk = true, Make = "Ford", Model = "Focus", Year = 2019 };
            var motorcycle = new Motorcycle() { HasSideCart = true, Make = "Harley Davidson", Model = "Roadster", Year = 2017};
            Vehicle sedan = new Car() { hasTrunk = true, Make = "Porsche", Model = "Panamera", Year = 2020 };
            Vehicle coupe = new Car() { hasTrunk = true, Make = "Honda", Model = "Accord", Year = 2015 };



            /*
             * Done - Add the 4 vehicles to the list
             * Done- Using a foreach loop iterate over each of the properties
             */

            vehicles.Add(focus);
            vehicles.Add(motorcycle);
            vehicles.Add(sedan);
            vehicles.Add(coupe);

            foreach(var veh in vehicles) 
            {
                Console.WriteLine{$"Make {veh.Make} Model {veh.Model} Year {veh.Year}");
                veh.DriveAbstract();
            }

            // Done - Call each of the drive methods for one car and one motorcycle

            #endregion            
            Console.ReadLine();
        }
    }
Example #2
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            var vehicles = new List <Vehicle>();

            var myCar = new Car();

            var myMotorcycle = new Motorcycle();

            Vehicle newCar = new Car();

            Vehicle newMoto = new Motorcycle();

            myCar.HasFourWheels = true;
            myCar.HasTrunk      = true;

            myMotorcycle.HasSideCar = false;
            myMotorcycle.IsACruiser = true;

            newCar.Make  = "Ford";
            newCar.Model = "Mustang";
            newCar.Year  = 2012;

            newMoto.DriveAbstract();


            vehicles.Add(myCar);
            vehicles.Add(myMotorcycle);
            vehicles.Add(newCar);
            vehicles.Add(newMoto);

            foreach (var vehicle in vehicles)
            {
                Console.WriteLine(vehicle.Make);
                Console.WriteLine(vehicle.Model);
                Console.WriteLine(vehicle.Year);
                vehicle.DriveAbstract();
                vehicle.DriveVirtual();
                Console.WriteLine(" ");
                Console.WriteLine(" ");
                Console.WriteLine("********************");
            }

            // Create a list of Vehicle called vehicles

            /*
             * Create 4 instances: 1 Car, 1 Motorcycle,
             * and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes -Done
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            // Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }
Example #3
0
        static void Main(string[] args)
        {
            Car        car        = new Car(2017, "Marcedenz", "Bnz", true);
            Motorcycle motorcycle = new Motorcycle(2021, "Bike", "Bk", false);

            Vehicle car1        = new Car(2001, "Toyota", "Camry", true);
            Vehicle motorcycle1 = new Motorcycle(2018, "Mtbs", "Mt", true);

            var vehicles = new List <Vehicle>();

            vehicles.Add(car);
            vehicles.Add(car1);
            vehicles.Add(motorcycle);
            vehicles.Add(motorcycle1);

            foreach (Vehicle item in vehicles)
            {
                item.DriveAbstract();
                item.DriveVirtual();
            }

            Console.WriteLine($"The number of cars are: {vehicles.Count()}");

            //Console.WriteLine(car.Year = 2018);
            //Console.WriteLine(car.Make = "Toyota");
            //Console.WriteLine(car.Model = "Camry");

            //Console.WriteLine(motorcycle.Year = 2010);
            //Console.WriteLine(motorcycle.Make = "BMW");
            //Console.WriteLine(motorcycle.Model = "BMW CSV");

            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * Create an abstract class called Vehicle
             * The vehicle class shall have three string properties Year, Make, and Model
             * Set the defaults to something generic in the Vehicle class
             * Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Provide the implementations for the abstract methods
             * Only in the Motorcycle class will you override the virtual drive method
             */

            // Create a list of Vehicle called vehicles

            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            // Call each of the drive methods for one car and one motorcycle

            #endregion
            // Console.ReadLine();
        }
Example #4
0
        static void Main(string[] args)
        {
            #region Vehicles

            /*
             * DONE---Create an abstract class called Vehicle
             * DONE---The vehicle class shall have three string properties Year, Make, and Model
             * DONE--- Set the defaults to something generic in the Vehicle class
             * DONE---Vehicle shall have an abstract method called DriveAbstract with no implementation
             * DONE---Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */


            /* DONE---
             * DONE---Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * DONE---Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * DONE---Provide the implementations for the abstract methods
             * DONE---Only in the Motorcycle class will you override the virtual drive method
             */

            /*
             * DONE--- Create a list of Vehicle called vehicles
             * DONE--- Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * DONE--- new it up as one of each derived class
             * DONE---Set the properties with object initializer syntax
             * DONE--- Add the 4 vehicles to the list
             * DONE---  Using a foreach loop iterate over each of the properties
             * DONE-- - Call each of the drive methods for one car and one motorcycle
             */

            var vehicles = new List <Vehicle>();
            Car focus    = new Car()
            {
                HasTrunk = true, Make = "Jeep", Model = "Wrangler", Year = 2021
            };
            Motorcycle senke = new Motorcycle()
            {
                HasSideCart = false, Make = "Senke", Model = "Boda", Year = 2020,
            };

            Vehicle camry = new Car()
            {
                HasTrunk = false, Make = "Toyota", Model = "Camry", Year = 2009,
            };
            Vehicle dodge = new Car()
            {
                Make = "Dodge", Model = "Sedan", Year = 2006,
            };

            vehicles.Add(dodge);
            vehicles.Add(camry);
            vehicles.Add(senke);
            vehicles.Add(focus);

            foreach (var veh in vehicles)
            {
                Console.WriteLine($"Make: { veh.Make}, Model: { veh.Model}, Year: { veh.Year}. ");
                veh.DriveAbstract();
                Console.WriteLine("----------------------------------------");
            }
            #endregion
            Console.ReadLine();
        }
Example #5
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * DONE -  Create an abstract class called Vehicle
             * DONE - The vehicle class shall have three string properties Year, Make, and Model
             * DONE - Set the defaults to something generic in the Vehicle class
             * DONE - Vehicle shall have an abstract method called DriveAbstract with no implementation
             * DONE - Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * DONE - Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * DONE -  Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * DONE - Provide the implementations for the abstract methods
             * DONE -Only in the Motorcycle class will you override the virtual drive method
             */

            // Create a list of Vehicle called vehicles
            var vechiles = new List <Vechile>();

            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */
            var focus = new Car()
            {
                HasTrunk = true, Make = "Ford", Model = "Focus", Year = 2013
            };
            var motorcycle = new Motorcycle()
            {
                HasSideCart = true, Make = "HD", Model = "Chopper", Year = 1978
            };

            Vechile sedan = new Car()
            {
                Make = "Dodge", Model = "Blah", Year = 2019
            };
            Vechile sport = new Car()
            {
                HasTrunk = false, Make = "Ferari", Model = "Something", Year = 200
            };

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */
            vechiles.Add(focus);
            vechiles.Add(motorcycle);
            vechiles.Add(sedan);
            vechiles.Add(sport);

            foreach (var veh in vechiles)
            {
                Console.WriteLine($"Make {veh.Make} Model {veh.Model} Year {veh.Year}");
                veh.DriveVirtual();
                Console.WriteLine("-----------------------");
            }

            // Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }
Example #6
0
        static void Main(string[] args)
        {
            // Create a list of Vehicle called vehicles
            var vehicles = new List <Vehicle>();

            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */
            Car myCar = new Car()
            {
                HasTrunk = true,
                Make     = "Honda",
                Model    = "Fit",
                Year     = 2010
            };

            Motorcycle myMoto = new Motorcycle()
            {
                HasSideCart = false,
                Make        = "HD",
                Model       = "Chopper",
                Year        = 1978
            };

            Vehicle sedan = new Car()
            {
                Make  = "Dodge",
                Model = "Plymoth",
                Year  = 1992
            };

            Vehicle sport = new Car()
            {
                HasTrunk = false,
                Make     = "Chevrolet",
                Model    = "Corvette",
                Year     = 1978
            };


            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */
            vehicles.Add(myCar);
            vehicles.Add(myMoto);
            vehicles.Add(sedan);
            vehicles.Add(sport);

            foreach (var item in vehicles)
            {
                Console.WriteLine($"Make: {item.Make} Model: {item.Model} Year: {item.Year}");
                item.DriveVirtual();
                Console.WriteLine("---------------------------------------------");
            }

            // Call each of the drive methods for one car and one motorcycle

            Console.ReadLine();
        }
Example #7
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * Done - Create an abstract class called Vehicle
             * Done - The vehicle class shall have three string properties Year, Make, and Model
             * Done - Set the defaults to something generic in the Vehicle class
             * Done - Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Done - Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * Done - Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Done - Add a distinct property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Done - Provide the implementations for the abstract methods
             * Done - Only in the Motorcycle class will you override the virtual drive method
             */

            // Create a list of Vehicle called vehicles
            var vehicles = new List <Vehicle>();

            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */
            var car = new Car()
            {
                HasTrunk = true, Make = "BMW", Model = "650i", Year = 2012
            };
            var motorcycle = new Motorcycle()
            {
                HasSideCart = false, Make = "Honda", Model = "1000",
            };

            Vehicle accord = new Car()
            {
                Make = "Honda", Model = "Accord", Year = 2020
            };
            Vehicle benz = new Car()
            {
                Make = "Mercedez", Model = "S550", Year = 2018
            };

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */
            vehicles.Add(car);
            vehicles.Add(motorcycle);
            vehicles.Add(accord);
            vehicles.Add(benz);

            foreach (var veh in vehicles)
            {
                Console.WriteLine($"Make: {veh.Make} Model: {veh.Model} Year: {veh.Year}");
                veh.DriveAbstract();
                Console.WriteLine("------------------------------");
            }

            // Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }
Example #8
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * DONE Create an abstract class called Vehicle
             * DONE The vehicle class shall have three string properties Year, Make, and Model
             * DONE Set the defaults to something generic in the Vehicle class
             * DONE Vehicle shall have an abstract method called DriveAbstract with no implementation
             * DONE Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * DONE Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * DONE Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * DONE Provide the implementations for the abstract methods
             * DONE Only in the Motorcycle class will you override the virtual drive method
             */

            // DONECreate a list of Vehicle called vehicles

            /*
             * DONE Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * DONE Set the properties with object initializer syntax
             */

            /*
             * DONE Add the 4 vehicles to the list
             * DONE Using a foreach loop iterate over each of the properties
             */

            // DONE Call each of the drive methods for one car and one motorcycle

            var vehicles = new List <Vehicle>();

            var Xterra = new Car()
            {
                HasHatchBack = true, Make = "Nissan", Model = "Xterra", Year = 2011
            };
            Car Accord = new Car()
            {
                HasHatchBack = false, Make = "Honda", Model = "Accord", Year = 2000
            };
            var Motorcycle = new Motorcycle()
            {
                Make = "Kawasaki", Model = "Ninja", Year = 2006
            };
            Car ForRunner = new Car()
            {
                HasHatchBack = true, Make = "Toyota", Model = "ForRunner", Year = 2016
            };
            Vehicle SantaFe = new Car()
            {
                HasHatchBack = true, Make = "Hyundai", Model = "Santa Fe", Year = 2015
            };

            vehicles.Add(Xterra);
            vehicles.Add(Accord);
            vehicles.Add(ForRunner);
            vehicles.Add(SantaFe);
            vehicles.Add(Motorcycle);

            foreach (var motor in vehicles)
            {
                Console.WriteLine($"Make: {motor.Make} Model: {motor.Model} Year: {motor.Year}");
                motor.DriveVirtual();
                Console.WriteLine("---------------------------------------------------------");
            }


            #endregion
            Console.ReadLine();
        }
Example #9
0
        static void Main(string[] args)
        {
            #region Vehicles

            /*
             * DONE* Create an abstract class called Vehicle
             * DONE* The vehicle class shall have three string properties Year, Make, and Model
             * DONE* Set the defaults to something generic in the Vehicle class
             * DONE* Vehicle shall have an abstract method called DriveAbstract with no implementation
             * DONE* Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * DONE* Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * DONE* Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * DONE* Provide the implementations for the abstract methods
             * DONE* Only in the Motorcycle class will you override the virtual drive method
             */

            // Create a list of Vehicle called vehicles

            var vehicles = new List <Vehicle>();


            /*
             * DONE* Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * DONE* - new it up as one of each derived class
             * DONE* Set the properties with object initializer syntax
             */

            Car terrian = new Car()
            {
                HasTrunk = true, Make = "GMC", Model = "Terrain", Year = 2019
            };
            Motorcycle motorcycle = new Motorcycle()
            {
                HasSideCart = true, Make = "Harley", Model = "cool", Year = 2020
            };

            Vehicle sedan = new Car()
            {
                HasTrunk = false, Make = "Honda", Model = "Civic", Year = 2014
            };
            Vehicle sport = new Car()
            {
                HasTrunk = true, Make = "Chevy", Model = "Corevette", Year = 2008
            };


            vehicles.Add(terrian);
            vehicles.Add(motorcycle);
            vehicles.Add(sedan);
            vehicles.Add(sport);

            foreach (var veh in vehicles)
            {
                Console.WriteLine($"Make {veh.Make} Model {veh.Model} Year {veh.Year}");
                veh.DriveAbstract();
            }

            /*
             * DONE* Add the 4 vehicles to the list
             * DONE* Using a foreach loop iterate over each of the properties
             *
             *
             */

            // *DONE* Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * DONE - Create an abstract class called Vehicle
             * DONE - The vehicle class shall have three string properties Year, Make, and Model
             * DONE - Set the defaults to something generic in the Vehicle class
             * DONE - Vehicle shall have an abstract method called DriveAbstract with no implementation
             * DONE - Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * DONE - Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * DONE - Add a distinct property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * DONE - Provide the implementations for the abstract methods
             * DONE - Only in the Motorcycle class will you override the virtual drive method
             */

            // Create a list holding type Vehicle called vehicles
            // do that here
            var vehicles = new List <Vehicle>();

            /*
             * Create 4 instances: 1 Car, 1 Motorcycle,
             * and then 2 instances of type Vehicle (use explicit typing) but use constructors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */

            //create a Car object and set values in its properties
            var sedan = new Car()
            {
                HasTrunk = true, make = "Olds", model = "Cutlass", year = 1972
            };

            //create a MotorCycle object and set values in its properties
            var motorcycle = new Motorcycle()
            {
                HasSideCart = true, make = "Honda", model = "550"
            };

            // twice - create an object of type vehicle with explicit typing: Vehicle whatever = new Car();
            Vehicle sedan2 = new Car()
            {
                make = "Acura", model = "TL", year = 2002
            };

            Vehicle sedan3 = new Car()
            {
                make = "Toyota", model = "Corolla", year = 2003
            };

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            // Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }
Example #11
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * Create an abstract class called Vehicle
             * The vehicle class shall have three string properties Year, Make, and Model
             * Set the defaults to something generic in the Vehicle class
             * Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Provide the implementations for the abstract methods
             * Only in the Motorcycle class will you override the virtual drive method
             */

            // Create a list of Vehicle called vehicles
            var vehicles = new List <Vehicle>();

            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */
            Car item1 = new Car("2021", "Audi", "A4 2.0T", "Black", 4, true);
            vehicles.Add(item1);

            Motorcycle item2 = new Motorcycle("2021", "Susuki", "Katana", "Gold", false, "Sprot");
            vehicles.Add(item2);

            Vehicle item3 = new Car()
            {
                Year       = "2019",
                Make       = "BMW",
                Model      = "6 Series 640i",
                Color      = "Glacier Silver",
                numOfDoors = 2,
                isSport    = true
            };
            vehicles.Add(item3);

            Vehicle item4 = new Car()
            {
                Year       = "2020",
                Make       = "Dodge",
                Model      = "Challenger",
                Color      = "Pearl White",
                numOfDoors = 2,
                isSport    = true
            };
            vehicles.Add(item4);



            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */
            foreach (var product in vehicles)
            {
                Console.WriteLine($"Year: {product.Year} \n" +
                                  $"Make: {product.Make} \n" +
                                  $"Model: {product.Model} \n" +
                                  $"Color: {product.Color}");
                Console.WriteLine();
            }



            // Call each of the drive methods for one car and one motorcycle
            item1.DriveAbstract();
            item2.DriveVirtual();
            item3.DriveVirtual();
            item4.DriveAbstract();

            #endregion
            Console.ReadLine();
        }
Example #12
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * Create an abstract class called Vehicle
             * The vehicle class shall have three string properties Year, Make, and Model
             * Set the defaults to something generic in the Vehicle class
             * Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Provide the implementations for the abstract methods
             * Only in the Motorcycle class will you override the virtual drive method
             */

            // Create a list of Vehicle called vehicles


            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing)
             * but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */


            Car mazda = new Car()
            {
                Make = "Mazda", Model = "Protege", Year = 2016
            };
            Motorcycle motor = new Motorcycle()
            {
                Make = "Suzuki", Model = "Posh", Year = 2030
            };

            Vehicle nissan = new Car();
            Vehicle honda  = new Motorcycle()
            {
                Year = 2020, Model = "Accord", Make = "Honda"
            };

            var vehicles = new List <Vehicle>();
            // List<Vehicle> vehicles1 = new List<Vehicle>();  explicit typing.
            vehicles.Add(mazda);
            vehicles.Add(nissan);
            vehicles.Add(honda);
            vehicles.Add(motor);


            foreach (var item in vehicles)
            {
                Console.WriteLine($"I have {vehicles.Count}  vehicles in my list.Which are {item.Make} {item.Model}");
            }



            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            foreach (var vehicle in vehicles)
            {
                Console.WriteLine($" {vehicle.Make } {vehicle.Model} & {vehicle.Year}");
                Console.WriteLine($" ");
            }


            // Call each of the drive methods for one car and one motorcycle


            mazda.DriveAbstract();
            mazda.DriveVirtual();

            motor.DriveAbstract();
            motor.DriveVirtual();
            #endregion
            Console.ReadLine();
        }
Example #13
0
        static void Main(string[] args)
        {
            var vehicles = new List <Vehicle>();

            var juansCar = new Car()
            {
                Year = 2021, Make = "Ford", Model = "Explorer"
            };
            var juansMotorcycle = new Motorcycle()
            {
                Year = 2019, Make = "Harley", Model = "Kt500"
            };
            Vehicle juanOneVehicle = new Car()
            {
                Year = 2017, Make = "Toyota", Model = "Camry"
            };
            Vehicle juanTwoVehicle = new Motorcycle()
            {
                Year = 2015, Make = "Honda", Model = "Ninja300"
            };

            vehicles.Add(juansCar);
            vehicles.Add(juansMotorcycle);
            vehicles.Add(juanOneVehicle);
            vehicles.Add(juanTwoVehicle);

            foreach (var vehicle in vehicles)
            {
                Console.WriteLine($"My {vehicle.Model} it's mark is {vehicle.Make} and it is of {vehicle.Year}");
            }

            juansCar.DriveAbstract();
            juansCar.DriveVirtual();
            juansMotorcycle.DriveAbstract();
            juansMotorcycle.DriveVirtual();
            juanOneVehicle.DriveAbstract();
            juanOneVehicle.DriveVirtual();
            juanTwoVehicle.DriveAbstract();
            juanTwoVehicle.DriveVirtual();



            /*
             * Todo follow all comments!!
             */

            #region Vehicles



            // Create a list of Vehicle called vehicles

            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            // Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }
Example #14
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles


            /*
             * DONE - Create an abstract class called Vehicle
             * DONE - The vehicle class shall have three string properties Year, Make, and Model
             * DONE - Set the defaults to something generic in the Vehicle class
             * DONE - Vehicle shall have an abstract method called DriveAbstract with no implementation
             * DONE - Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * DONE - Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * DONE - Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * DONE - Provide the implementations for the abstract methods
             * DONE -Only in the Motorcycle class will you override the virtual drive method
             */

            // DONE - Create a list of Vehicle called vehicles
            var vehicles = new List <Vehicle>();

            /*
             * DONE - Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * DONE - Set the properties with object initializer syntax
             */
            Car fiesta = new Car()
            {
                HasTrunk = true, Make = "Ford", Model = "Fiesta", Year = "2010"
            };
            Motorcycle yamaha = new Motorcycle()
            {
                HasSideCar = false, Make = "Yamaha", Model = "Ninja", Year = "2015"
            };
            Vehicle GrandCherokee = new Car()
            {
                HasTrunk = false, Model = "Grand Cherokee", Year = "2018", Make = "Jeep"
            };
            Vehicle harley = new Motorcycle()
            {
                HasSideCar = true, Make = "Harley", Year = "2017", Model = "HardTail"
            };



            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            vehicles.Add(fiesta);
            vehicles.Add(yamaha);
            vehicles.Add(GrandCherokee);
            vehicles.Add(harley);

            foreach (var vehicle1 in vehicles)
            {
                Console.WriteLine($"Make {vehicle1.Make} Model {vehicle1.Model} Year {vehicle1.Year}");
                Console.WriteLine(" ");
                vehicle1.DriveAbstract();
                Console.WriteLine("-------------------------------- ");
            }

            // DONE - Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * Create an abstract class called Vehicle -- DONE
             * The vehicle class shall have three string properties Year, Make, and Model -- Done
             * Set the defaults to something generic in the Vehicle class -- DONE
             * Vehicle shall have an abstract method called DriveAbstract with no implementation -- DONE
             * Vehicle shall have a virtual method called DriveVirtual with a base implementation. -- DONE
             */

            /*
             * Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle -- DONE
             * Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle -- DONE
             * Provide the implementations for the abstract methods -- DONE
             * Only in the Motorcycle class will you override the virtual drive method -- DONE
             */

            // Create a list of Vehicle called vehicles

            var vehicles = new List <Vehicle>();

            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */

            Car fusion = new Car()
            {
                Make     = "Ford",
                Model    = "Fusion",
                Year     = 2019,
                HasTrunk = true
            };

            Motorcycle harley = new Motorcycle()
            {
                Make        = "Harley Davidson",
                Model       = "Street 750",
                Year        = 2020,
                HasSideCart = false
            };

            Vehicle sedan = new Car()
            {
                Make     = "Infinity",
                Model    = "Q70L",
                Year     = 2019,
                HasTrunk = true
            };

            Vehicle muscle = new Car()
            {
                Make     = "Dodge",
                Model    = "Viper",
                Year     = 2018,
                HasTrunk = false
            };

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            vehicles.Add(muscle);
            vehicles.Add(sedan);
            vehicles.Add(harley);
            vehicles.Add(fusion);

            foreach (var veh in vehicles)
            {
                Console.WriteLine($"Year: {veh.Year}");
                Console.WriteLine($"Make: {veh.Make}");
                Console.WriteLine($"Model: {veh.Model}");
                veh.DriveAbstract();
                veh.DriveVirtual();
                Console.WriteLine();
            }

            // Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }
Example #16
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * Create an abstract class called Vehicle
             * The vehicle class shall have three string properties Year, Make, and Model
             * Set the defaults to something generic in the Vehicle class
             * Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Provide the implementations for the abstract methods
             * Only in the Motorcycle class will you override the virtual drive method
             */

            // Create a list of Vehicle called vehicles
            var vehicles = new List <Vehicle>();


            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */
            Car van = new Car()
            {
                Make = "Ford", HasTrunk = true, CarType = "Van", Year = 2010,
            };
            Motorcycle bicycle = new Motorcycle()
            {
                NumOfWheels = 2
            };
            Vehicle truck         = new Car();
            Vehicle anActualSheep = new Motorcycle()
            {
                NumOfWheels = 0, GasMileage = 99999999
            };

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            vehicles.Add(van);
            vehicles.Add(truck);
            vehicles.Add(bicycle);
            vehicles.Add(anActualSheep);
            foreach (var item in vehicles)
            {
                Console.WriteLine($"Make: {item.Make} Model: {item.Model} Year: {item.Year}");
                item.DriveAbstract();
            }
            // Call each of the drive methods for one car and one motorcycle
            anActualSheep.DriveVirtual();
            van.DriveAbstract();
            #endregion
            Console.ReadLine();
        }
Example #17
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            // Create a list of Vehicle called vehicles

            var vehicles = new List <Vehicles>();

            var ford = new Car();

            ford.DriveAbstract();
            ford.DriveVirtual();
            ford.Make  = "Ford";
            ford.Model = "Mustang";
            ford.Year  = "2020";

            var harley = new Motorcycle();

            ford.DriveAbstract();
            ford.DriveVirtual();
            harley.Make  = "Harley";
            harley.Model = "Davidson";
            vehicles.Add(harley);
            vehicles.Add(ford);

            var chevy = new Car()
            {
                Model    = "Corvette",
                Make     = "Chevy",
                HasTrunk = false
            };

            vehicles.Add(chevy);

            foreach (var item in vehicles)
            {
                Console.WriteLine($"{item.Make} { item.Model} { item.Year}");
            }



            /*
             * Create 4 instances, 1 Car, 1 Motorcycle, and then 2 Vehicles - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            // Call each of the drive methods for one car and one motorcycle

            #region Vehicles

            /*
             * Create an abstract class called Vehicle
             * The vehicle class shall have three string properties Year, Make, and Model
             * Set the defaults to something generic in the Vehicle class
             * Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Provide the implementations for the abstract methods
             * Only in the Motorcycle class will you override the virtual drive method
             */

            // Create a list of Vehicle called vehicles

            /*
             * Create 4 instances, 1 Car, 1 Motorcycle, and then 2 Vehicles - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            // Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * DONE Create an abstract class called Vehicle
             * DONE The vehicle class shall have three string properties Year, Make, and Model
             * DONE  Set the defaults to something generic in the Vehicle class
             * DONE Vehicle shall have an abstract method called DriveAbstract with no implementation
             * DONE Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             * DONE
             */

            /*
             * DONE Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * DONE Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * DONEProvide the implementations for the abstract methods
             * DONE Only in the Motorcycle class will you override the virtual drive method
             *
             */

            // Create a list of Vehicle called vehicles
            // Done

            var vehicles = new List <Vehicle>();

            /*
             * DONE Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * DONE - new it up as one of each derived class
             * DONE Set the properties with object initializer syntax
             *
             */

            Car newCar = new Car()
            {
                HasTrunk = true,
                Model    = "3285i",
                Make     = "Bmw",
                Year     = 1993
            };

            Motorcycle motorcycle = new Motorcycle()
            {
                HasSideCart = true,
                Make        = "Harley",
                Model       = "Pink",
                Year        = 1999
            };

            Vehicle sedan = new Car()
            {
                Year     = 2020,
                Model    = "Polaris",
                Make     = "GroundCrew 3s",
                HasTrunk = true
            };



            Vehicle sport = new Car()
            {
                Year     = 2003,
                Make     = "Convertible",
                Model    = "Ford Fusion",
                HasTrunk = false
            };



            /*
             * DONE Add the 4 vehicles to the list
             * DONE Using a foreach loop iterate over each of the properties
             */

            vehicles.Add(newCar);
            vehicles.Add(motorcycle);
            vehicles.Add(sedan);
            vehicles.Add(sport);

            foreach (var veh in vehicles)
            {
                Console.WriteLine($"Make {veh.Make} Model {veh.Model}  Year {veh.Year}");
                veh.DriveAbstract();
                veh.DriveVirtual();
                Console.WriteLine("----------------------------------------------");
            }


            // DONE Call each of the drive methods for one car and one motorcycle

            motorcycle.DriveAbstract();
            sport.DriveVirtual();

            #endregion
            Console.ReadLine();
        }
Example #19
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * Done: Create an abstract class called Vehicle
             * Done: The vehicle class shall have three string properties Year, Make, and Model
             * Done: Set the defaults to something generic in the Vehicle class
             * Done: Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Done: Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * Done: Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Done: Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Done: Provide the implementations for the abstract methods
             * Done: Only in the Motorcycle class will you override the virtual drive method
             */

            // Done: Create a list of Vehicle called vehicles
            var vehicles = new List <Vehicle>();

            /*
             * Done: Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Done: Set the properties with object initializer syntax
             */
            Car focus = new Car()
            {
                HasTrunk = true, Make = "Ford", Model = "Focus", Year = 2010
            };
            Motorcycle motorcycle = new Motorcycle()
            {
                HasSidecart = true, Make = "Honda", Model = "XR 75", Year = 2000
            };
            Vehicle sedan = new Car()
            {
                HasTrunk = true, Make = "Volvo", Model = "S60", Year = 2007
            };
            Vehicle compact = new Car()
            {
                HasTrunk = false, Make = "Geo", Model = "Metro", Year = 1993
            };

            /*
             * Done: Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */
            vehicles.Add(focus);
            vehicles.Add(motorcycle);
            vehicles.Add(sedan);
            vehicles.Add(compact);

            foreach (var veh in vehicles)
            {
                Console.WriteLine($"Make: {veh.Make}, Model: {veh.Model}, Year: {veh.Year}");
                veh.DriveVirtual();
                Console.WriteLine("---------------------------");
            }
            // Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }
Example #20
0
        static void Main(string[] args)
        {
            List <Vehicle> list = new List <Vehicle>();

            Car sedan = new Car()
            {
                Make = "Toyota", Model = "Sierra", Year = 1999
            };
            Vehicle tricycle = new Motorcycle()
            {
                Make = "tricycle", Model = "Honda", HasSideCar = false
            };
            Vehicle sixWheel = new Car()
            {
                Make = "Chevy", Model = "truck"
            };
            Vehicle harley = new Motorcycle()
            {
                Make = "Harley", Model = "Thunder", Year = 2009
            };

            list.Add(sedan);
            list.Add(tricycle);
            list.Add(sixWheel);
            list.Add(harley);
            foreach (var item in list)
            {
                Console.WriteLine(item.ToString());
            }

            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * Create an abstract class called Vehicle
             * The vehicle class shall have three string properties Year, Make, and Model
             * Set the defaults to something generic in the Vehicle class
             * Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Provide the implementations for the abstract methods
             * Only in the Motorcycle class will you override the virtual drive method
             */

            // Create a list of Vehicle called vehicles

            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            // Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }
Example #21
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * Create an abstract class called Vehicle
             * The vehicle class shall have three string properties Year, Make, and Model
             * Set the defaults to something generic in the Vehicle class
             * Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */



            /*
             * Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Provide the implementations for the abstract methods
             * Only in the Motorcycle class will you override the virtual drive method
             */



            // Create a list of Vehicle called vehicles

            var vehicles = new List <Vehicle>();

            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */

            //car
            var car1 = new Car()
            {
                HasTrunk = true, Make = "Ford", Model = "Focus", Year = 2013
            };

            //motorcycle
            var motor1 = new Motorcycle()
            {
                HasSideCart = true, Make = "he", Model = "Chopper", Year = 1888
            };

            // 2 instances of type vehicle
            Vehicle sedan = new Car()
            {
                Make = "Dodge", Model = "Blah", Year = 2000
            };
            Vehicle sport = new Car()
            {
                Make = "damn", Model = "Tesla", Year = 2015
            };


            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            vehicles.Add(sedan);
            vehicles.Add(motor1);
            vehicles.Add(car1);
            vehicles.Add(motor1);

            foreach (var vehicle in vehicles)
            {
                Console.WriteLine(vehicle.Make);
                Console.WriteLine(vehicle.Model);
                Console.WriteLine(vehicle.Year);
            }

            // Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }
Example #22
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            var vehicles = new List <Vehicle>();

            Car c = new Car();

            c.Name     = "Car 1";
            c.Year     = "1990";
            c.Make     = "Honda";
            c.Model    = "Civic";
            c.HasTrunk = true;

            Motorcycle m = new Motorcycle();

            m.Name       = "Motorcycle 1";
            m.Year       = "2009";
            m.Make       = "Kawasaki";
            m.Model      = "Ninja";
            m.HasSideCar = true;

            Vehicle v1 = new Car();

            v1.Name  = "Vehicle 1";
            v1.Year  = "2016";
            v1.Make  = "Nissan";
            v1.Model = "Rogue";

            Vehicle v2 = new Motorcycle();

            v2.Name  = "Vehicle 2";
            v2.Year  = "1966";
            v2.Make  = "BMW";
            v2.Model = "Bike";

            vehicles.Add(c);
            vehicles.Add(m);
            vehicles.Add(v1);
            vehicles.Add(v2);

            foreach (var item in vehicles)
            {
                Console.WriteLine($"Here are the stats on {item.Name}:");
                Console.WriteLine(item.Year);
                Console.WriteLine(item.Make);
                Console.WriteLine(item.Model);
                Console.WriteLine("");
            }

            c.DriveAbstract();
            Console.WriteLine("");
            c.DriveVirtual();
            Console.WriteLine("");
            m.DriveAbstract();
            Console.WriteLine("");
            m.DriveVirtual();


            #region Vehicles

            /*
             * Create an abstract class called Vehicle
             * The vehicle class shall have three string properties Year, Make, and Model
             * Set the defaults to something generic in the Vehicle class
             * Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Provide the implementations for the abstract methods
             * Only in the Motorcycle class will you override the virtual drive method
             */

            // Create a list of Vehicle called vehicles

            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            // Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }
Example #23
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * Create an abstract class called Vehicle
             * The vehicle class shall have three string properties Year, Make, and Model
             * Set the defaults to something generic in the Vehicle class
             * Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Provide the implementations for the abstract methods
             * Only in the Motorcycle class will you override the virtual drive method
             */

            // Create a list of Vehicle called vehicles

            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            // Call each of the drive methods for one car and one motorcycle

            List <Vehicle> vehicle = new List <Vehicle>();

            Car gavinCar = new Car();
            gavinCar.hasTrunk = true;
            gavinCar.make     = "Buic";
            gavinCar.model    = "Laceern";
            gavinCar.year     = 2008;

            Motorcycle gavinsMot = new Motorcycle();
            gavinsMot.hasSideCart = false;
            gavinsMot.make        = "Harly";
            gavinsMot.model       = "Davison";
            gavinsMot.year        = 2000;

            Car danniesCar = new Car();
            danniesCar.hasTrunk = true;
            danniesCar.year     = 2012;
            danniesCar.make     = "Ford";
            danniesCar.model    = "Fushion";

            Car bresCar = new Car();
            bresCar.hasTrunk = true;
            bresCar.year     = 1999;
            bresCar.make     = "Chevy";
            bresCar.model    = "Cruiz";

            gavinsMot.DriveVirtual();
            gavinCar.DriveAbstract();
            danniesCar.DriveAbstract();
            bresCar.DriveAbstract();

            vehicle.Add(gavinCar);
            vehicle.Add(gavinsMot);
            vehicle.Add(danniesCar);
            vehicle.Add(bresCar);
            Console.WriteLine("--------------------------------------------");

            foreach (var item in vehicle)
            {
                Console.WriteLine($"Make: {item.make} , Model: {item.model} ,  Year: {item.year}  ");
                item.DriveAbstract();
                item.DriveVirtual();
                Console.WriteLine("//////////////////////////////////////");
            }
            {
            }



            #endregion
            Console.ReadLine();
        }
Example #24
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * Done - Create an abstract class called Vehicle
             * Done - The vehicle class shall have three string properties Year, Make, and Model
             * Done - Set the defaults to something generic in the Vehicle class
             * Done - Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Done - Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * Done - Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Done - Add a distinct property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Done - Provide the implementations for the abstract methods
             * Done - Only in the Motorcycle class will you override the virtual drive method
             */

            // Done - Create a list of Vehicle called vehicles

            var vehicles = new List <Vehicle>();

            /*
             * Done - Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * Done - new it up as one of each derived class
             * Done - Set the properties with object initializer syntax
             */

            Car focus = new Car()
            {
                HasSeatBelts = true, Make = "Ford", Model = "Focus", Year = "2013"
            };
            Motorcycle motorcycle = new Motorcycle()
            {
                HasSideCar = false, Make = "Ace", Model = "XP-4", Year = "1923"
            };

            Vehicle sedan = new Car()
            {
                Make = "Dodge", Model = "Thingie", Year = "2019"
            };
            Vehicle sport = new Car()
            {
                HasSeatBelts = false, Make = "Ferrari", Model = "Fancy", Year = "2021"
            };

            /*
             * Done - Add the 4 vehicles to the list
             * Done - Using a foreach loop iterate over each of the properties
             */

            vehicles.Add(sedan);
            vehicles.Add(sport);
            vehicles.Add(focus);
            vehicles.Add(motorcycle);

            foreach (var veh in vehicles)
            {
                Console.WriteLine($"{veh.Year} {veh.Make} {veh.Model}.");
                //veh.DriveAbstract();
                //veh.DriveVirtual();
                //Console.WriteLine("__________________________________");
            }

            // Done - Call each of the drive methods for one car and one motorcycle

            motorcycle.DriveVirtual();
            sedan.DriveAbstract();


            #endregion
            Console.ReadLine();
        }
Example #25
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * Create an abstract class called Vehicle
             * The vehicle class shall have three string properties Year, Make, and Model
             * Set the defaults to something generic in the Vehicle class
             * Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Provide the implementations for the abstract methods
             * Only in the Motorcycle class will you override the virtual drive method
             */

            // Create a list of Vehicle called vehicles

            var vehicles = new List <vehicle>();

            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */

            Car Golf = new Car()
            {
                HasTrunk = true, Year = 2016, Make = "Volkswagen", Model = "Golf"
            };
            Motorcycle Spider = new Motorcycle()
            {
                HasSideCart = false, Year = 2019, Make = "Kawasaki", Model = "Ninja"
            };

            vehicle Equinox = new Car()
            {
                Make = "GM", Model = "Equinox XL", Year = 2014
            };
            vehicle Altima = new Car()
            {
                HasTrunk = true, Make = "Nissan", Model = "Altima Sport", Year = 2015
            };

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            vehicles.Add(Golf);
            vehicles.Add(Spider);
            vehicles.Add(Equinox);
            vehicles.Add(Altima);

            foreach (var item in vehicles)
            {
                Console.WriteLine($" Make {item.Make}, Model {item.Model} and Year {item.Year}");
                item.DriveVirtual();
                Console.WriteLine("---------------------------------------------");
            }

            // Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }
Example #26
0
        static void Main(string[] args)
        {
            /*
             * Todo follow all comments!!
             */

            #region Vehicles

            /*
             * Create an abstract class called Vehicle
             *
             *
             * The vehicle class shall have three string properties Year, Make, and Model
             * Set the defaults to something generic in the Vehicle class
             * Vehicle shall have an abstract method called DriveAbstract with no implementation
             * Vehicle shall have a virtual method called DriveVirtual with a base implementation.
             */

            /*
             * Now create 2 non-abstract classes: Car and Motorcycle, that inherit from Vehicle
             * Add a distict property in the 2 derived classes such as HasTrunk for Car and HasSideCart for Motorcycle
             * Provide the implementations for the abstract methods
             * Only in the Motorcycle class will you override the virtual drive method
             */

            // Create a list of Vehicle called vehicles

            var vehicles = new List <Vehicle>();



            /*
             * Create 4 instances: 1 Car, 1 Motorcycle, and then 2 instances of type Vehicle (use explicit typing) but use constuctors from derived classes
             * - new it up as one of each derived class
             * Set the properties with object initializer syntax
             */

            Car focus = new Car()
            {
                HasTrunk = "Yes", Make = "Ford", Model = "Focus", Year = 2016,
            };
            Car civic = new Car()
            {
                HasTrunk = "No", Make = "Honda", Model = "Civic", Year = 2017,
            };
            Motorcycle harely = new Motorcycle()
            {
                HassideCart = "Yes", Make = "Davidson", Model = "Harley", Year = 2001,
            };

            Vehicle sedan = new Car()
            {
                HasTrunk = "Yes", Make = "Ford", Model = "Mustang", Year = 2001,
            };
            Vehicle sport = new Car()
            {
                HasTrunk = "No", Make = "Lexus", Model = "X90", Year = 2018,
            };

            /*
             * Add the 4 vehicles to the list
             * Using a foreach loop iterate over each of the properties
             */

            vehicles.Add(focus);
            vehicles.Add(civic);
            vehicles.Add(harely);
            vehicles.Add(sedan);
            vehicles.Add(sport);

            foreach (var item in vehicles)
            {
                Console.WriteLine($"-------------------------");
                Console.WriteLine($"Make: {item.Make}, Model: {item.Make}, Year: {item.Year}");
                item.DriveAbstract();
                item.DriveVirtual();
            }



            // Call each of the drive methods for one car and one motorcycle

            #endregion
            Console.ReadLine();
        }