Beispiel #1
0
        static void Main(string[] args)
        {
            //TODO

            //Create a seperate class file called Car - done
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable - done
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise() - done
            //The methods should take one string parameter: the respective noise property - done

            //Now that the Car class is created we can instanciate 3 new cars - done
            //Set the properties for each of the cars - done
            //Call each of the methods for each car - done


            var myCar = new Car();

            // Version 1: DOT NOTATION
            myCar.Make        = "Honda";
            myCar.Model       = "Civic";
            myCar.Year        = 2014;
            myCar.EngineNoise = "vroom";
            myCar.HonkNoise   = "honk";
            myCar.IsDriveable = true;


            var parkersCar = new Car()
            {
                //Version 2: OBJECT INITIALIZER SYNTAX
                Make        = "Mazda",
                Model       = "3",
                Year        = 2014,
                EngineNoise = "vroom vroom",
                HonkNoise   = "beep",
                IsDriveable = true
            };

            //Version 3: (USING THE CONSTRUCTOR TO ALLOW PARAMETER VALUES TO BE PLACED INSIDE PROPERTIES)
            var dollysCar = new Car("Mustang", "Viper", 2019, "VRROOM", "HONK", true);


            //calling the methods
            parkersCar.MakeEngineNoise($"Parker's car goes {parkersCar.EngineNoise},");

            dollysCar.MakeEngineNoise($"Dolly's car goes {dollysCar.EngineNoise}.");

            parkersCar.MakeHonkNoise(parkersCar.HonkNoise);

            dollysCar.MakeHonkNoise(dollysCar.HonkNoise);


            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console


            var vehicleOne = new Car(2018, "Volkswagon", "Beetle", "Vroom", "Beep", true);

            var vehicleTwo = new Car();

            vehicleTwo.Year        = 2012;
            vehicleTwo.Make        = "Nissan";
            vehicleTwo.Model       = "Juke";
            vehicleTwo.EngineNoise = "Nerrrmmm";
            vehicleTwo.HonkNoise   = "Beep Beep";
            vehicleTwo.IsDriveable = true;

            var vehicleThree = new Car()
            {
                Year        = 2015,
                Make        = "Suburu",
                Model       = "Forrester",
                EngineNoise = "vRROOOmmmm",
                HonkNoise   = "Honk",
                IsDriveable = true,
            };


            vehicleOne.MakeEngineNoise();
            vehicleOne.MakeHonkNoise();
            vehicleTwo.MakeEngineNoise();
            vehicleTwo.MakeHonkNoise();
            vehicleThree.MakeEngineNoise();
            vehicleThree.MakeHonkNoise();
        }
        static void Main(string[] args)
        {
            var vehicle1 = new Car();
            var vehicle2 = new Car();
            var vehicle3 = new Car();

            List <string> ModelList = new List <string>();


            Console.WriteLine($"Howdy and welcome to Honest Abe's carlot!");

            vehicle1.Year = 1965;
            vehicle1.Make = "Ford";
            ModelList.Add(vehicle1.Make);
            vehicle1.Model       = "Mustang";
            vehicle1.EngineNoise = "";
            vehicle1.HonkNoise   = "Honk, honk";
            vehicle1.IsDriveable = false;
            vehicle1.IsLoud      = true;
            vehicle1.MakeEngineNoise();
            vehicle1.MakeHonkNoise();

            vehicle2.Year = 1978;
            vehicle2.Make = "Volkswagen";
            ModelList.Add(vehicle2.Make);
            vehicle2.Model       = "Super Beetle Convertible";
            vehicle2.EngineNoise = "Rrrrrrroom";
            vehicle2.HonkNoise   = "Meep, meep";
            vehicle2.IsDriveable = true;
            vehicle2.IsLoud      = true;
            vehicle2.MakeEngineNoise();
            vehicle2.MakeHonkNoise();

            vehicle3.Year = 2003;
            vehicle3.Make = "Toyota";
            ModelList.Add(vehicle3.Make);
            vehicle3.Model       = "Prius";
            vehicle3.EngineNoise = "Purrrrrrr";
            vehicle3.HonkNoise   = "Yeeeep";
            vehicle3.IsDriveable = true;
            vehicle3.IsLoud      = false;
            vehicle3.MakeEngineNoise();
            vehicle3.MakeHonkNoise();


            Console.WriteLine("--------------------------");
            Console.WriteLine($"You're in luck, we have {ModelList.Count} models on the lot today!");

            foreach (var item in ModelList)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("Which one can I show you?");
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property
            //DONE - See car class

            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car
            // DONE - See below
            //Using the constructor
            var carOne = new Car(2003, "Honda", "Civic", "Klunk", "Beep beep!", false);

            Console.WriteLine($"The new number of cars on the lot are: {CarLot.numberOfCars}");
            //Using the Set properties
            var carTwo = new Car();

            Console.WriteLine($"The new number of cars on the lot are: {CarLot.numberOfCars}");
            carTwo.Year        = 2012;
            carTwo.Make        = "GMC";
            carTwo.Model       = "Denali";
            carTwo.EngineNoise = "ROAAAR";
            carTwo.HonkNoise   = "BLAAAM";
            carTwo.IsDrivable  = true;
            //Using object initializer
            var carThree = new Car()
            {
                Year = 2020, Make = "Ford", Model = "Mustang", EngineNoise = "Vrooom", HonkNoise = "Breee", IsDrivable = true
            };

            Console.WriteLine($"The new number of cars on the lot are: {CarLot.numberOfCars}");
            //Call each of the methods for each car DONE - See Below
            carOne.MakeEngineNoise(carOne.EngineNoise);
            carOne.MakeHonkNoise(carOne.HonkNoise);
            carTwo.MakeEngineNoise(carTwo.EngineNoise);
            carTwo.MakeHonkNoise(carTwo.HonkNoise);
            carThree.MakeEngineNoise(carThree.EngineNoise);
            carThree.MakeHonkNoise(carThree.HonkNoise);

            //*************BONUS X 2*************//
            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
            //DONE - See below
            foreach (var car in CarLot.Cars)
            {
                Console.WriteLine($"{car.Year}, {car.Make}, {car.Model}");
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            CarLot lot = new CarLot();

            Car bmw = new Car();

            lot.CarList.Add(bmw);

            bmw.Year        = 2016;
            bmw.Make        = "BMW";
            bmw.Model       = "328i";
            bmw.EngineNoise = "Vroom";
            bmw.HonkNoise   = "Beep Boop";
            bmw.IsDriveable = true;

            bmw.MakeEngineNoise();
            bmw.MakeHonkNoise();

            //Object initializer syntax
            Car celica = new Car()
            {
                Year = 2000, Make = "Toyota", Model = "Celica", EngineNoise = "Nothing", HonkNoise = "Help"
            };

            lot.CarList.Add(celica);

            celica.MakeEngineNoise();
            celica.MakeHonkNoise();

            //Constructor initialization
            Car mustang = new Car(2018, "Ford", "Mustang", "Vroom", "Honk");

            lot.CarList.Add(mustang);

            mustang.MakeEngineNoise();
            mustang.MakeHonkNoise();

            Console.WriteLine("------------------");

            //*************BONUS X 2*************//
            Console.WriteLine($"Number of cars created: {CarLot.numberOfCars}");

            foreach (var car in lot.CarList)
            {
                Console.WriteLine();
                Console.WriteLine($"Year: {car.Year} Make: {car.Make} Model: {car.Model}");
            }

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
        static void Main(string[] args)
        {
            var lot = new Carlot();

            Car mustang = new Car()
            {
                Year = 2004, Make = "Ford", Model = "Mustang"
            };

            mustang.MakeEngineNoise();
            mustang.MakeHonkNoise();

            lot.CarList.Add(mustang);
Beispiel #7
0
        static void Main(string[] args)
        {
            var FordTBird = new Car("Ford", "Thunderbird", 1955, "HONK", true, true);



            Console.WriteLine($"This is a {FordTBird.Year} {FordTBird.Make} {FordTBird.Model} and I shall now demostrate some features, noteably the horn first.");

            FordTBird.MakeHonkNoise();

            Console.WriteLine($"NOW!, Let's see if she runs!");
            FordTBird.MakeEngineNoise();



            var CadillacSeville = new Car("Cadillac", "Seville", 1959, "HONK", true, true);



            Console.WriteLine($"This is a {CadillacSeville.Year} {CadillacSeville.Make} {CadillacSeville.Model}. A Big girl indeed, 20 feet long if You can imagine it! As per routine, I shall now demostrate some features, noteably the horn first.");
            CadillacSeville.MakeHonkNoise();
            Console.WriteLine($"NOW!, Let's see if she runs!");
            CadillacSeville.MakeEngineNoise();


            var Packard = new Car("Packard", "Deluxe Phaeton", 1931, "HONK", true, true);



            Console.WriteLine($"This is a {Packard.Year} {Packard.Make} {Packard.Model}. A Big girl indeed, 20 feet long if You can imagine it! As per routine, I shall now demostrate some features, noteably the horn first.");
            Packard.MakeHonkNoise();
            Console.WriteLine($"NOW!, Let's see if she runs!");
            Packard.MakeEngineNoise();


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            var ford = new Car();

            ford.Year        = "2015";
            ford.Make        = "Ford";
            ford.Model       = "Explorer";
            ford.EngineNoise = "vroom";
            ford.HonkNoise   = "honk";
            ford.IsDriveable = true;

            ford.MakeEngineNoise(ford.EngineNoise);
            ford.MakeHonkNoise(ford.HonkNoise);
            Console.ReadLine();


            Car chevy = new Car()
            {
                Year        = "2015",
                Make        = "Chevy",
                Model       = "Malibu",
                EngineNoise = "vroom",
                HonkNoise   = "honk",
                IsDriveable = true
            };

            chevy.MakeEngineNoise(chevy.EngineNoise);
            chevy.MakeHonkNoise(chevy.HonkNoise);
            Console.ReadLine();


            //var honda = new Car();
            //honda.Year = "2015";
            //honda.Make = "Honda";
            //honda.Model = "Accord";
            //honda.EngineNoise = "vroom";
            //honda.HonkNoise = "honk";
            //honda.IsDriveable = true;

            //honda.MakeEngineNoise(honda.EngineNoise);
            //honda.MakeHonkNoise(honda.HonkNoise);
            //Console.ReadLine();


            Car honda = new Car("2015", "Honda", "Accord", "vroom", "honk", true);

            honda.MakeEngineNoise(honda.EngineNoise);
            honda.MakeHonkNoise(honda.HonkNoise);
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property - I did not do this - Bool instead.


            //Now that the Car class is created we can instanciate 3 new cars - DONE
            var Car1 = new Car()
            {
                Year = 1988, Make = "Nissan", Model = "Pathfinder", EngineNoise = true, HonkNoise = true, IsDriveable = true
            };
            var Car2 = new Car()
            {
                Year = 2000, Make = "Ford", Model = "Focus", EngineNoise = false, HonkNoise = false, IsDriveable = true
            };
            var Car3 = new Car()
            {
                Year = 2019, Make = "Chevy", Model = "Impalla", EngineNoise = true, HonkNoise = false, IsDriveable = true
            };

            //Set the properties for each of the cars - DONE

            //Call each of the methods for each car - DONE
            Car1.MakeEngineNoise();
            Car2.MakeEngineNoise();
            Car3.MakeEngineNoise();

            Car1.MakeHonkNoise();
            Car2.MakeHonkNoise();
            Car3.MakeHonkNoise();

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            Car car1 = new Car("Ford", "Fiesta", 2011);

            car1.MakeEngineNoise("Vroom");
            car1.MakeHonkNoise("Beeep beep!");
            car1.WhatIsThatIHear();

            Car car2 = new Car("Volkswagon", "Tiguan", 2017);

            car2.MakeEngineNoise("Zoom Zoom");
            car2.MakeHonkNoise("Honk hooonnnkk");
            car2.WhatIsThatIHear();

            Car car3 = new Car("Ford", "F150", 2019);

            car3.MakeEngineNoise("Chug chug chug");
            car3.MakeHonkNoise("bonk bonk!");
            car3.WhatIsThatIHear();


            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            Car car1 = new Car();

            Console.WriteLine($" Car Year: {car1.Year = 2009} \n Car make: {car1.Make = "Honda"} \n car model: {car1.Model = "Accord"} \n Car Engine:  {car1.EngineNoise = "Good"} \n Honk Noise: {car1.HonkNoise = "Great"}\n Is drivable?  {car1.IsDriveable = "Yes"} ");

            Console.WriteLine(car1.MakeEngineNoise("Very Nice"));
            Console.WriteLine(car1.MakeHonkNoise("Good Honk"));

            Car car2 = new Car();

            Car car3 = new Car();

            Console.WriteLine($"Number of car created: {CarLotSimulator.CarLot.numberOfCars}");



            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Beispiel #12
0
        static void Main(string[] args)
        {
            var cars = new CarLot();
            var c1   = new Car();

            c1.Year        = 2020;
            c1.Make        = "Ford";
            c1.Model       = "Focus";
            c1.HonkNoise   = "Beep";
            c1.EngineNoise = "Vroom";
            cars.AddCar(c1);

            var c2 = new Car(2019, "Dodge", "Colt", "epp", "BrrBrr");

            cars.AddCar(c2);

            var c3 = new Car()
            {
                Year        = 2018,
                Make        = "Toyota",
                Model       = "Camery",
                HonkNoise   = "meep",
                EngineNoise = "chukachuka"
            };

            cars.AddCar(c3);

            c1.MakeEngineNoise();
            c1.MakeHonkNoise();

            c2.MakeEngineNoise();
            c2.MakeHonkNoise();

            c3.MakeEngineNoise();
            c3.MakeHonkNoise();

            Console.WriteLine(cars);
            Console.WriteLine($"Number of Cars in Lot: {CarLot.numberOfCars}");
        }
Beispiel #13
0
        static void Main(string[] args)
        {
            //TODO



            //At the end iterate through the list printing each of car's Year, Make, and Model to the console

            CarLot lot = new CarLot();


            Car car1 = new Car(2013, "BMW", "M3", "Vroom(in german)", "Das honk", true);

            lot.CarList.Add(car1);
            car1.MakeEngineNoise();
            car1.MakeHonkNoise();

            Car car2 = new Car(2020, "Toyota", "Supra", "Whaaahhh", "meep", true);

            lot.CarList.Add(car2);
            car2.MakeEngineNoise();
            car2.MakeHonkNoise();

            Car car3 = new Car(2009, "Ford", "Mustang", "Clank", "Neigh", false);

            lot.CarList.Add(car3);
            car3.MakeEngineNoise();
            car3.MakeHonkNoise();



            foreach (var car in lot.CarList)
            {
                Console.WriteLine($"{car.Year} {car.Make} {car.Model} ");
                Console.WriteLine($"{car.Model} goes {car.EngineNoise} and says { car.HonkNoise} ");
            }
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            Carlot lot = new Carlot();


            Car bmw = new Car();

            lot.CarList.Add(bmw);
            bmw.Year        = 2003;
            bmw.Make        = "bmw";
            bmw.Model       = "328i";
            bmw.EngineNoise = "Waaw!";
            bmw.HonkNoise   = "Beeeep";
            bmw.IsDriveable = true;

            bmw.MakeEngineNoise();
            bmw.MakeHonkNoise();

            Car celica = new Car()
            {
                Year = 1999, Make = "Toyota", Model = "Celica", EngineNoise = "N/A", HonkNoise = "Whomp"
            };

            lot.CarList.Add(celica);


            celica.MakeEngineNoise();
            celica.MakeHonkNoise();

            Car Titan = new Car(2020, "Nissan", "Titan", "N/A", "Whaaaank");

            lot.CarList.Add(Titan);

            Titan.MakeEngineNoise();
            Titan.MakeHonkNoise();

            //*************BONUS X 2*************//

            foreach (var car in lot.CarList)
            {
                Console.WriteLine($"Year :{car.Year}, Make: {car.Make} Model: {car.Model}");
            }

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property

            Car green = new Car();

            green.Year        = 1970;
            green.Make        = "ford";
            green.Model       = "F-150";
            green.EngineNoise = "loud";
            green.HonkNoise   = "Noticeable";
            green.IsDriveable = "teleporting";
            green.EngineNoise = "Loud";
            green.HonkNoise   = "Noticeable";

            green.MakeEngineNoise(green.EngineNoise);
            green.MakeHonkNoise(green.HonkNoise);

            Console.WriteLine(carlot.numberOfCars);

            Car black = new Car();

            black.Year        = 2019;
            black.Make        = "honda";
            black.Model       = "accord";
            black.EngineNoise = "low";
            black.HonkNoise   = "Noticeable";
            black.IsDriveable = "ghosting";
            black.EngineNoise = "low";
            black.HonkNoise   = "Noticeable";

            black.MakeEngineNoise(black.EngineNoise);
            black.MakeHonkNoise(black.HonkNoise);


            Console.WriteLine(carlot.numberOfCars);

            Car burgundy = new Car();

            burgundy.Make        = "bugatti";
            burgundy.Model       = "spinner";
            burgundy.EngineNoise = "jaws";
            burgundy.HonkNoise   = "yoda";
            burgundy.IsDriveable = "flying";
            burgundy.EngineNoise = "jaws";
            burgundy.HonkNoise   = "yoda";

            burgundy.MakeEngineNoise(burgundy.EngineNoise);
            burgundy.MakeHonkNoise(burgundy.HonkNoise);


            Console.WriteLine(carlot.numberOfCars);

            Console.ReadLine();
            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Beispiel #16
0
        static void Main(string[] args)
        {
            //TODO
            //DONE Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            var lot = new CarLot();



            //DONE Create a seperate class file called Car
            //DONE Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //DONE Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //DONEThe methods should take one string parameter: the respective noise property


            //DONE Now that the Car class is created we can instanciate 3 new cars
            //DONE Set the properties for each of the cars
            //DONE Call each of the methods for each car


            //Instantiation 1 - using dot notation
            var firstCar = new Car();

            firstCar.Make        = "Toyota";
            firstCar.Model       = "Corolla";
            firstCar.Year        = 2005;
            firstCar.EngineNoise = "vroom";
            firstCar.HonkNoise   = "hooonk";
            firstCar.IsDriveable = false;

            lot.Cars.Add(firstCar);



            //Instantiation 2 - using dot notation
            var secondCar = new Car();

            secondCar.Make        = "Chrevolet";
            secondCar.Model       = "Malibu";
            secondCar.Year        = 2007;
            secondCar.EngineNoise = "vroom";
            secondCar.HonkNoise   = "beeeep";
            secondCar.IsDriveable = true;

            lot.Cars.Add(secondCar);



            //Instantiation 3 - object initializer syntax
            var thirdCar = new Car()
            {
                Make        = "Kia",
                Model       = "Soul",
                Year        = 2016,
                EngineNoise = "vroom",
                HonkNoise   = "tooot",
                IsDriveable = true
            };

            lot.Cars.Add(thirdCar);

            //Instantiation 4 - using the constructor to allow parameter values to be placed inside properties
            //all values for each parameter but be included using this syntax
            var fourthCar = new Car(2015, "Volkswagen", "Beetle", "vroooooooom", "ahroooogahh", true);

            lot.Cars.Add(fourthCar);

            //Calling methods
            firstCar.MakeEngineNoise(firstCar.EngineNoise);
            firstCar.MakeHonkNoise(firstCar.HonkNoise);

            secondCar.MakeEngineNoise(secondCar.EngineNoise);
            secondCar.MakeHonkNoise(secondCar.HonkNoise);

            thirdCar.MakeEngineNoise(thirdCar.EngineNoise);
            thirdCar.MakeHonkNoise(thirdCar.HonkNoise);

            fourthCar.MakeEngineNoise(fourthCar.EngineNoise);
            fourthCar.MakeHonkNoise(fourthCar.HonkNoise);



            //*************BONUS*************//

            // DONE Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //DONE Create a CarLot class
            //DONE It should have at least one property: a List of cars

            //DONE At the end iterate through the list printing each of car's Year, Make, and Model to the console

            foreach (var car in lot.Cars)
            {
                Console.WriteLine($"Year: { car.Year} Make: { car.Make} Model: {car.Model}");
            }
        }
Beispiel #17
0
        static void Main(string[] args)
        {
            var Carlist = new Carlot();

            Car mustang = new Car()
            {
                Year = 2004, Make = "Ford", Model = "Mustang"
            };

            mustang.MakeEngineNoise("VROOOOM");
            mustang.MakeHonkNoise("Beep");
            var Inventory = new Carlot()
            {
                Carlist = (Car)mustang
            };



            Car Cherokee = new Car();

            Cherokee.Year  = 1974;
            Cherokee.Make  = "Jeep";
            Cherokee.Model = "Cherokee";
            Cherokee.MakeEngineNoise("Sputter");
            Cherokee.MakeHonkNoise("Meep");

            Carlist.Add(Cherokee);


            Car Corolla = new Car()
            {
                Year  = 2008,
                Make  = "Toyota",
                Model = "Corolla"
            };

            Corolla.MakeEngineNoise("whir");
            Corolla.MakeHonkNoise("Clown horn sound");

            Carlist.Add(Corolla);

            foreach (var x in Carlist)
            {
                Console.WriteLine(x);
            }

            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Beispiel #18
0
        public static void Main(string[] args)
        {
            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property


            CarLot lot = new CarLot(); //bonus 2

            //Now that the Car class is created we can instanciate 3 new cars
            Car car1 = new Car();

            //adding car to list from bonus 2
            lot.CarList.Add(car1);

            //Set the properties for each of the cars

            //Standard member initializer syntax:
            car1.Make        = "Toyota";
            car1.Model       = "Camry";
            car1.Year        = 2000;
            car1.EngineNoise = "";
            car1.HonkNoise   = "";
            car1.IsDriveable = true;
            //Call each of the methods for each car
            car1.MakeEngineNoise(car1.EngineNoise);
            car1.MakeHonkNoise(car1.HonkNoise);


            //Object initializer syntax
            var car2 = new Car()
            {
                Make = "Honda", Model = "Civic", Year = 2000, EngineNoise = "dead", HonkNoise = "rip", IsDriveable = false
            };

            //is var best practice or Car?
            //adding car to list from bonus 2
            lot.CarList.Add(car2);
            //Call each of the methods for each car
            car2.MakeEngineNoise(car2.EngineNoise);
            car2.MakeHonkNoise(car2.HonkNoise);


            //Constructor initializer syntax
            Car car3 = new Car("Tesla", "Model S", 2018, "pretty", "wow", true);

            //adding car to list from bonus 2
            lot.CarList.Add(car3);
            //Call each of the methods for each car
            car3.MakeEngineNoise(car3.EngineNoise);
            car3.MakeHonkNoise(car3.HonkNoise);

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car
            //See above answers - car1 used standard member initializer, car 2 did object initializer, car3 did constructor initializer


            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console

            foreach (var car in lot.CarList) //you have to do lot.CarList because CarList exists in CarLot class
            {
                Console.WriteLine($"Make     Model    Year");
                Console.WriteLine($"---------------------");
                Console.WriteLine($"{car.Make}   {car.Model}    {car.Year}"); //can't just do car.. you need to access the properties as well
                Console.WriteLine();
            }

            //Exercise 2 of Static Keyword lecture material:

            var honda = new Car();

            Console.WriteLine($"{CarLot2.NumberOfCars++}");

            var toyota = new Car();

            Console.WriteLine($"{CarLot2.NumberOfCars++}");

            var lexus = new Car();

            Console.WriteLine($"{CarLot2.NumberOfCars++}");
        }
Beispiel #19
0
        static void Main(string[] args)
        {
            var carLot = new CarLot();

            Console.WriteLine($"Number of cars: {CarLot.numberOfCars}");
            //TODO

            //Create a seperate class file called Car-DONE
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable-DONE
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()-DONE
            //The methods should take one string parameter: the respective noise property-DONE


            //Now that the Car class is created we can instanciate 3 new cars-DONE
            //Set the properties for each of the cars-DONE
            //Call each of the methods for each car-DONE

            var car1 = new Car();

            Console.WriteLine($"Number of cars: {CarLot.numberOfCars}");
            car1.Year        = 2010;
            car1.Make        = "Honda";
            car1.Model       = "CR-V";
            car1.EngineNoise = "Zooom";
            car1.HonkNoise   = "Beep Beep";
            car1.IsDriveable = true;

            var car2 = new Car()
            {
                Year        = 2018,
                Make        = "Dodge",
                Model       = "Charger",
                EngineNoise = "Whooom Whooom",
                HonkNoise   = "Whoomp Whooomp",
                IsDriveable = true
            };

            Console.WriteLine($"Number of cars: {CarLot.numberOfCars}");

            Car car3 = new Car(5000, "Jupiter LTD", "WhirlyBird", "Whirrrrrrr", "Do space ships Honk?", true);

            Console.WriteLine($"Number of cars: {CarLot.numberOfCars}");

            car1.MakeEngineNoise();
            car1.MakeHonkNoise();
            Console.WriteLine();

            car2.MakeEngineNoise();
            car2.MakeHonkNoise();
            Console.WriteLine();

            car3.MakeEngineNoise();
            car3.MakeHonkNoise();
            Console.WriteLine();


            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car-DONE



            //*************BONUS X 2*************//



            //Create a CarLot class-DONE
            //It should have at least one property: a List of cars-DONE
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.-DONE
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console-DONE

            carLot.ParkingLot = new List <Car>()
            {
                car1, car2, car3
            };

            foreach (var car in carLot.ParkingLot)
            {
                Console.WriteLine($"{car.Year} {car.Make} {car.Model}");
                car.MakeEngineNoise();
                car.MakeHonkNoise();
                Console.WriteLine("----------------------------");
            }
            Console.WriteLine($"Number of cars: {CarLot.numberOfCars}");
        }
Beispiel #20
0
        static void Main(string[] args)
        {
            var carLot = new CarLot();

            //Using dot notation.
            var jakesCar = new Car();

            jakesCar.Make        = "Jeep";
            jakesCar.Model       = "Cherokee";
            jakesCar.Year        = 2016;
            jakesCar.EngineNoise = "Vroom";
            jakesCar.HonkNoise   = "Boop boop";
            jakesCar.IsDrivable  = true;

            //Object Initializer Syntax
            var lukesCar = new Car()
            {
                Make        = "Ford",
                Model       = "F150",
                Year        = 2008,
                EngineNoise = "Sputter",
                HonkNoise   = "Honk honk",
                IsDrivable  = false
            };

            //Using the constructor to allow parameter values to be placed inside properties.
            var johnsCar = new Car(2013, "Honda", "Civic", "Zoom", "Beep beep", true);

            lukesCar.MakeHonkNoise();
            lukesCar.MakeEngineNoise();

            johnsCar.MakeHonkNoise();
            johnsCar.MakeEngineNoise();

            jakesCar.MakeHonkNoise();
            jakesCar.MakeEngineNoise();

            jakesCar.CarDetails();

            carLot.LotList.Add(jakesCar);
            carLot.LotList.Add(johnsCar);
            carLot.LotList.Add(lukesCar);

            foreach (var car in carLot.LotList)
            {
                Console.WriteLine($"Year: {car.Year} Make: {car.Make} Model: {car.Model}");
            }

            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Beispiel #21
0
        static void Main(string[] args)
        {
            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property
            //DONE (but I ended up taking out method perameters)


            //Now that the Car class is created we can instantiate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car
            //DONE

            var inventory = new List <CarLotSimulator.Car>();

            var sweetVintageRides = new CarLot(inventory);

            var car1 = new Car(1966, "Dodge", "Charger", "vroorooooom", "beepbeep!", true);

            inventory.Add(car1);
            car1.MakeEngineNoise();
            car1.MakeHonkNoise();

            var car2 = new Car();

            car2.Year        = 1956;
            car2.Make        = "Mercedes";
            car2.Model       = "SL 300 Gullwing";
            car2.EngineNoise = "hhhhrrrrraaaarrrrrrhhhhh";
            car2.HonkNoise   = "HONK";
            car2.IsDriveable = true;
            inventory.Add(car2);
            car2.MakeEngineNoise();
            car2.MakeHonkNoise();

            var car3 = new Car()
            {
                Year        = 1952,
                Make        = "Rolls-Royce",
                Model       = "Silver Dawn",
                EngineNoise = "grrrmmmbbgrrrmmmmb",
                HonkNoise   = "aooogah!!",
                IsDriveable = true
            };

            inventory.Add(car3);
            car3.MakeEngineNoise();
            car3.MakeHonkNoise();

            Console.WriteLine();
            Console.WriteLine($"There are {CarLot.numberOfCars} cars available now:");
            Console.WriteLine();

            foreach (CarLotSimulator.Car car in inventory)
            {
                Console.WriteLine($"Currently available: {car.Year} {car.Make} {car.Model}.");
            }

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car
            //DONE

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
            //DONE
        }
Beispiel #22
0
        static void Main(string[] args)
        {
            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property

            //Base Constructor
            Car bmw = new Car();

            bmw.Year        = 2016;
            bmw.Make        = "BMW";
            bmw.Model       = "325i";
            bmw.EngineNoise = "RRMmmmrrrr";
            bmw.HonkNoise   = "Beep";
            bmw.IsDriveable = true;

            //Object Initializer Syntax
            Car Octane = new Car {
                Year = 2015, Make = "Octane", Model = "Octane Rush", EngineNoise = "VROOM", HonkNoise = "Boop", IsDriveable = true
            };

            //
            Car Mustang = new Car();

            Mustang.Year        = 2019;
            Mustang.Make        = "Mustang";
            Mustang.Model       = "Mach 1";
            Mustang.EngineNoise = "Brap";
            Mustang.HonkNoise   = "Beep Bop";
            Mustang.IsDriveable = true;


            Console.WriteLine($"This car is a {Mustang.Year} {Mustang.Make}  and it's a {Mustang.Model}.");
            Mustang.MakeEngineNoise();
            Mustang.MakeHonkNoise();
            Console.WriteLine("");

            Console.WriteLine($"This car is a {Octane.Year} {Octane.Make} and it's a {Octane.Model}.");
            Octane.MakeEngineNoise();
            Octane.MakeHonkNoise();
            Console.WriteLine("");

            Console.WriteLine($"This car is a {bmw.Year} {bmw.Make} and it is a {bmw.Model}.");
            bmw.MakeEngineNoise();
            bmw.MakeHonkNoise();
            Console.WriteLine("");


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
        static void Main(string[] args)
        {
            //TODO

            CarLot lot = new CarLot();

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            var carOne = new Car();

            carOne.Make        = "Ford";
            carOne.Model       = "Escape";
            carOne.Year        = 2020;
            carOne.IsDriveable = true;
            carOne.HonkNoise   = "beep";
            carOne.EngineNoise = "brum - brum";

            Car carTwo = new Car {
                Make        = "Chevrolet", Model = "Impala", Year = 2020,
                EngineNoise = "Vroom", HonkNoise = "beep beep beep", IsDriveable = true
            };

            Car carThree = new Car {
                Make = "Nissan", Model = "Sentra", Year = 2020, EngineNoise = "Vroom Vroom", HonkNoise = "BEEP BEEP", IsDriveable = true
            };

            //Call each of the methods for each car
            carOne.MakeEngineNoise(carOne.EngineNoise);
            carOne.MakeHonkNoise(carOne.HonkNoise);

            lot.carLot.Add(carOne);

            carTwo.MakeEngineNoise(carTwo.EngineNoise);
            carTwo.MakeHonkNoise(carTwo.HonkNoise);

            lot.carLot.Add(carTwo);

            carThree.MakeEngineNoise(carThree.EngineNoise);
            carThree.MakeHonkNoise(carThree.HonkNoise);

            lot.carLot.Add(carThree);


            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console

            foreach (var car in lot.carLot)
            {
                Console.WriteLine("************************************");
                Console.WriteLine($"{car.Make} {car.Model} {car.Year}");
                Console.WriteLine("************************************");
            }
        }
Beispiel #24
0
        static void Main(string[] args)
        {
            var carLot = new CarLot();



            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            //*************BONUS*************//
            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //dot notation
            var firstCar = new Car();

            firstCar.Make        = "Old Man Jenkins";
            firstCar.Model       = "Jalopy";
            firstCar.Year        = 1932;
            firstCar.EngineNoise = "Vroom!";
            firstCar.HonkNoise   = "Arooooga!";
            firstCar.IsDriveable = true;

            firstCar.MakeEngineNoise();
            firstCar.MakeHonkNoise();



            //object initializer syntax
            var secondCar = new Car()
            {
                Make        = "Ford",
                Model       = "Bronco",
                Year        = 2020,
                EngineNoise = "Rev rev!",
                HonkNoise   = "Woo woooo",
                IsDriveable = false
            };

            secondCar.MakeEngineNoise();
            secondCar.MakeHonkNoise();


            //using a constructor that utilizes parameters
            var thirdCar = new Car("Chevy", "Impala", 1964, "Vrommm!", "Beep!", true);

            thirdCar.MakeEngineNoise();
            thirdCar.MakeHonkNoise();

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console


            carLot.Cars.Add(firstCar);
            carLot.Cars.Add(secondCar);
            carLot.Cars.Add(thirdCar);



            foreach (Car vehicle in carLot.Cars)
            {
                Console.WriteLine($"This car is a {vehicle.Make} {vehicle.Model}, made in the year {vehicle.Year}.");
            }
        }
Beispiel #25
0
        static void Main(string[] args)
        {
            //TODO
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list. - DONE

            CarLot lot = new CarLot();

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property

            Car car1 = new Car();

            car1.Year        = 2018;
            car1.Model       = "CX9";
            car1.Make        = "Mazda";
            car1.IsDriveable = true;
            car1.EngineNoise = "noise1";
            car1.HonkNoise   = "honk1";

            var car2 = new Car()
            {
                Make        = "Jeep",
                Model       = "Wrangler",
                Year        = 2019,
                EngineNoise = "noise2",
                HonkNoise   = "honk2",
                IsDriveable = true
            };

            //Car car2 = new Car();
            //car2.Year = 2019;
            //car2.Model = "Wrangler";
            //car2.Make = "Jeep";
            //car2.IsDriveable = true;
            //car2.EngineNoise = "noise2";
            //car2.HonkNoise = "honk2";

            //Car car3 = new Car();
            //car3.Year = 2016;
            //car3.Model = "Grand Cherokee";
            //car3.Make = "Jeep";
            //car3.IsDriveable = true;
            //car3.EngineNoise = "noise3";
            //car3.HonkNoise = "honk3";


            Car car3 = new Car(2016, "Jeep", "Grand Cherokee", "noise3", "honk3", false);


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            car3.MakeEngineNoise("vrooom\n");
            car2.MakeHonkNoise("honk honk\n");

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //Create a CarLot class - DONE
            //It should have at least one property: a List of cars - DONE

            //instance name . property name . method name
            //"lot" instantiated at the beginning of the main program.
            //"Cars" is the list created in the CarLot class
            //"Add" is the built in method that adds value to the list
            //(car1)  instantiated from the Cars class with its properties declared
            lot.Cars.Add(car1);
            lot.Cars.Add(car2);
            lot.Cars.Add(car3);

            //At the end iterate through the list printing each of car's Year, Make, and Model to the console


            //get each value with properties declared from the list
            foreach (var car in lot.Cars)
            {
                Console.WriteLine($"Year: {car.Year} Make: {car.Make} Model: {car.Model}\n");
            }
        }
Beispiel #26
0
        static void Main(string[] args)
        {
            //TODO
            var carlot = new Carlot();

            //DONE Create a seperate class file called Car
            //DONE Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //DONE Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //DONE The methods should take one string parameter: the respective noise property



            //DONE Now that the Car class is created we can instanciate 3 new cars
            //DONE Set the properties for each of the cars
            //DONE Call each of the methods for each car

            Console.WriteLine($"Number of Cars created: {Carlot.numberOfCars}");

            var myCar = new Car();

            myCar.Driver      = "Graybles";
            myCar.Make        = "Honda";
            myCar.Model       = "Accord";
            myCar.Year        = 2008;
            myCar.EngineNoise = "vroom vroom";
            myCar.HonkNoise   = "beep beep";
            myCar.IsDriveable = true;


            Console.WriteLine($"Number of Cars created: {Carlot.numberOfCars}");

            var stevosCar = new Car()
            {
                Driver      = "StevO!",
                Year        = 2020,
                Make        = "Tonka",
                Model       = "Super Truck",
                EngineNoise = "boom boom",
                HonkNoise   = "caw caw",
                IsDriveable = false
            };

            Console.WriteLine($"Number of Cars created: {Carlot.numberOfCars}");

            var jakesCar = new Car("Jake", 2001, "Ford", "Focus", "skrrrrrt", "boop boop", true);

            Console.WriteLine($"Number of Cars created: {Carlot.numberOfCars}");

            var jebsCar = new Car()
            {
                Driver      = "J3BBY M@N3",
                Year        = 3000,
                Make        = "Mars",
                Model       = "Rover Rumbler",
                EngineNoise = "bleep blorp",
                HonkNoise   = "Zing Zoooop!!",
                IsDriveable = true
            };

            Console.WriteLine($"Number of Cars created: {Carlot.numberOfCars}");


            myCar.MakeEngineNoise(myCar.EngineNoise);

            myCar.MakeHonkNoise(myCar.HonkNoise);

            jakesCar.MakeEngineNoise(jakesCar.EngineNoise);

            jakesCar.MakeHonkNoise(jakesCar.HonkNoise);

            stevosCar.MakeEngineNoise(stevosCar.EngineNoise);

            stevosCar.MakeHonkNoise(stevosCar.HonkNoise);

            jebsCar.MakeEngineNoise(jebsCar.EngineNoise);

            jebsCar.MakeHonkNoise(jebsCar.HonkNoise);



            //*************BONUS*************//

            //DONE Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//
            carlot.carList.Add(myCar);
            carlot.carList.Add(stevosCar);
            carlot.carList.Add(jakesCar);
            carlot.carList.Add(jebsCar);


            foreach (var Car in carlot.carList)
            {
                Console.WriteLine($"Driver: {Car.Driver} Year: {Car.Year} Make: {Car.Make} Model: {Car.Model}");
            }
            //DONE Create a CarLot class
            //DONE It should have at least one property: a List of cars
            //DONE Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Beispiel #27
0
        static void Main(string[] args)
        {
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
            var lot = new CarLot();

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property


            //Now that the Car class is created we can instanciate 3 new car
            //Set the properties for each of the cars


            var myCar = new Car();

            myCar.Make        = "Chevy";
            myCar.Model       = "Cobalt";
            myCar.Year        = 2010;
            myCar.EngineNoise = "Weak";
            myCar.HonkNoise   = "Beeeeeeep";
            myCar.IsDriveable = true;

            lot.Cars.Add(myCar);
            //method 2
            var yourCar = new Car()
            {
                Make        = "Pontiac",
                Model       = "G6",
                Year        = 2005,
                EngineNoise = "Sports Car",
                HonkNoise   = "Brrrrrrp",
                IsDriveable = false,
            };

            lot.Cars.Add(yourCar);
            //method 3
            var otherCar = new Car(2006, "Ford", "f-150", "truck", "breeeep", true);

            lot.Cars.Add(otherCar);



            //Call each of the methods for each car
            myCar.MakeEngineNoise();
            yourCar.MakeEngineNoise();
            otherCar.MakeEngineNoise();

            myCar.MakeHonkNoise();
            yourCar.MakeHonkNoise();
            otherCar.MakeHonkNoise();

            Console.WriteLine($"Number of created cars: {CarLot.numberOfCars} ");

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



            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
        }
Beispiel #28
0
        static void Main(string[] args)
        {
            //DONE

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property

            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            //*************BONUS*************//
            // Set the properties utilizing the 3 different ways we learned about, one way for each car
            //public Car(int year, string make, string model, string engineNoise, string honkNoise, bool isDrivable = false)

            //BONUS X 2
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            CarLot carLot = new CarLot();

            //Standard Member Initialization
            Car car1 = new Car();

            carLot.carList.Add(car1);    //Add car1 to the CarLot List
            car1.Year        = 2020;
            car1.Make        = "Ford";
            car1.Model       = "Escape";
            car1.EngineNoise = "Vroom";
            car1.HonkNoise   = "Honk Honk";
            car1.IsDriveable = false;

            Console.WriteLine($"Car1 {car1.Year} {car1.Make} {car1.Model}");
            car1.MakeEngineNoise(car1.EngineNoise);
            car1.MakeHonkNoise(car1.HonkNoise);
            //Static Keyword Exercise 2- Increment the Number of Cars when a new Car is created
            Console.WriteLine($"Number of Cars in Lot = {(CarLot._numberOfCars)}");
            Console.WriteLine();

            //Object Initializer Syntax
            Car car2 = new Car()
            {
                Year        = 2019,
                Make        = "Toyota",
                Model       = "Camry",
                EngineNoise = "Smooth",
                HonkNoise   = "Beep Beep"
            };

            carLot.carList.Add(car2);  //Add car2 to the CarLot List
            Console.WriteLine($"Car2 {car2.Year} {car2.Make} {car2.Model}");
            car2.MakeEngineNoise(car2.EngineNoise);
            car2.MakeHonkNoise(car2.HonkNoise);
            //Static Keyword Exercise 2- Increment the Number of Cars when a new Car is created
            Console.WriteLine($"Number of Cars in Lot = {(CarLot._numberOfCars)}");
            Console.WriteLine();

            //Parameterized Constructor Initialization syntax
            Car car3 = new Car(2018, "Honda", "CRV", "Real Quiet", "Bee Boop");

            carLot.carList.Add(car3);  //Add car3 to the CarLot List
            Console.WriteLine($"Car3 {car3.Year} {car3.Make} {car3.Model}");
            car3.MakeEngineNoise(car3.EngineNoise);
            car3.MakeHonkNoise(car3.HonkNoise);
            //Static Keyword Exercise 2- Increment the Number of Cars when a new Car is created
            Console.WriteLine($"Number of Cars in Lot = {(CarLot._numberOfCars)}");
            Console.WriteLine();

            //*************BONUS X 2*************//
            //DONE -Create a CarLot class
            //DONE - It should have at least one property: a List of cars
            //DONE - Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
            foreach (Car car in carLot.carList)
            {
                Console.WriteLine($"Year = {car.Year} Make = {car.Make} = Model {car.Model}");
            }

            //Static Keyword Exercise 2- Increment the Number of Cars when a new Car is created
            Console.WriteLine($"Number of Cars in Lot = {(CarLot._numberOfCars)}");
        }
        static void Main(string[] args)
        {
            CarLot carLot = new CarLot();


            Console.WriteLine($"Number of cars {CarLot._numberOfCars}"); //this is implemented every time we call the car class.

            Car redCar = new Car(1995, "Jeep", "Grand Cherokee", "vroom vroom", "Beep Beep!", true);

            CarLot.CarList.Add(redCar);                                  //adding car to the list
            Console.WriteLine($"Number of cars {CarLot._numberOfCars}"); //this is implemented every time we call the car class.
            Car blueCar = new Car(2005, "Ford", "F150", "VRUMMMMMMMM!", "Doot Doot!", false);

            CarLot.CarList.Add(blueCar);
            Console.WriteLine($"Number of cars {CarLot._numberOfCars}"); //this is implemented every time we call the car class.
            Car blackCar = new Car(2020, "Tesle", "Mark3", "*krickits*", "squeek squeek!", false);

            CarLot.CarList.Add(blackCar);

            Console.WriteLine($"The number of cars made it {CarLot.CarList.Count}");
            Console.WriteLine($"Number of cars {CarLot._numberOfCars}"); //this is implemented every time we call the car class.

            Console.WriteLine("Here is the red cars stats!");
            Console.WriteLine($"{redCar.Year}, {redCar.Make}, {redCar.Model}, {redCar.IsDriveable}");
            Console.WriteLine("This cars engine goes!");
            Car.MakeEngineNoise(redCar.EngineNoise);
            Console.WriteLine("This cars horn goes!");
            Car.MakeHonkNoise(redCar.HonkNoise);
            Console.WriteLine("Press any key to see the next car!");
            Console.ReadLine();

            Console.WriteLine("Here is the blue cars stats!");
            Console.WriteLine($"{blueCar.Year}, {blueCar.Make}, {blueCar.Model}, {blueCar.IsDriveable}");
            Console.WriteLine("This cars engine goes!");
            Car.MakeEngineNoise(blueCar.EngineNoise);
            Console.WriteLine("This cars horn goes!");
            Car.MakeHonkNoise(blueCar.HonkNoise);
            Console.WriteLine("Press any key to see the next car!");
            Console.ReadLine();

            Console.WriteLine("Here is the black cars stats!");
            Console.WriteLine($"{blackCar.Year}, {blackCar.Make}, {blackCar.Model}, {blackCar.IsDriveable}");
            Console.WriteLine("This cars engine goes!");
            Car.MakeEngineNoise(blackCar.EngineNoise);
            Console.WriteLine("This cars horn goes!");
            Car.MakeHonkNoise(blackCar.HonkNoise);
            Console.WriteLine("Press any key to see the next car!");
            Console.ReadLine();

            foreach (Car car in CarLot.CarList)
            {
                Console.WriteLine($"Red Car stats: Year = {car.Year}, make = {car.Make}, model = {car.Model}");
            }



            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car?????

            Car car1 = new Car(); //method 1, long method

            car1.Year        = 1995;
            car1.Make        = "Jeep";
            car1.Model       = "Cherokee";
            car1.EngineNoise = "vvvooommm!";
            car1.HonkNoise   = "Bloop!";
            car1.IsDriveable = true;

            var car2 = new Car()//method 2
            {
                Year        = 1995,
                Make        = "Jeep",
                Model       = "Cherokee",
                EngineNoise = "vroomie",
                HonkNoise   = "pooooot",
                IsDriveable = false,
            };

            Car car3 = new Car(2020, "Tesle", "Mark3", "*krickits*", "squeek", false);//method 3. best way.


            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Beispiel #30
0
        static void Main(string[] args)
        {
            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console

            //Creat and object
            var carsOnLot = new CarLot();

            var carLotsCar1 = new Car()
            {
                Make        = "Ford",
                Model       = "Mustang GT",
                Year        = 2021,
                EngineNoise = "Loud",
                HonkNoise   = "Dukes of Hazard",
                IsDriveable = true,
            };

            carsOnLot.Cars.Add(carLotsCar1);



            Car carLotsCar2 = new Car();

            carLotsCar2.Make        = "Honda";
            carLotsCar2.Model       = "Accord";
            carLotsCar2.Year        = 2021;
            carLotsCar2.EngineNoise = "Loud";
            carLotsCar2.HonkNoise   = "Beep";
            carLotsCar2.IsDriveable = true;

            carsOnLot.Cars.Add(carLotsCar2);



            Car carLotsCar3 = new Car("Dodge", "Charger SRT", 2021, "Lions Roar", "Get Over Here!", true);

            carsOnLot.Cars.Add(carLotsCar3);


            Car carLotsCar4 = new Car();

            carLotsCar4.Make        = "Mercedes";
            carLotsCar4.Model       = "Benz";
            carLotsCar4.Year        = 2021;
            carLotsCar4.EngineNoise = "Quiet";
            carLotsCar4.HonkNoise   = "Mozart";
            carLotsCar4.IsDriveable = true;

            carsOnLot.Cars.Add(carLotsCar4);



            carLotsCar1.MakeEngineNoise(carLotsCar1.EngineNoise);

            carLotsCar2.MakeEngineNoise(carLotsCar2.EngineNoise);

            carLotsCar3.MakeEngineNoise(carLotsCar3.EngineNoise);

            carLotsCar4.MakeEngineNoise(carLotsCar4.EngineNoise);



            carLotsCar1.MakeHonkNoise(carLotsCar1.HonkNoise);

            carLotsCar2.MakeHonkNoise(carLotsCar2.HonkNoise);

            carLotsCar3.MakeHonkNoise(carLotsCar3.HonkNoise);

            carLotsCar4.MakeHonkNoise(carLotsCar4.HonkNoise);



            foreach (var vehicle in carsOnLot.Cars)
            {
                Console.WriteLine($"Car Year: {vehicle.Year}            Make: {vehicle.Make}               Model. {vehicle.Model }\n");
            }
        }