Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var lot = new CarLot();

            CarLot TimeToGo;

            var car1 = new Car(2021, "Toyota", "Corolla", "Vroom", "Beep", true);

            lot.Cars.Add(car1);

            var car2 = new Car(2020, "Nissan", "Frontier", "Brooom", "honk", true);

            lot.Cars.Add(car2);

            var car3 = new Car(1908, "Ford", "Model T", "Drooom", "Honk", false);

            lot.Cars.Add(car3);



            //Set the properties for each of the cars

            //Call each of the methods for each car
            car1.MakeEngineNoise();
            car2.MakeEngineNoise();
            car3.MakeEngineNoise();

            //*************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.Cars)
            {
                Console.WriteLine($"Year: {car.Year} Make: {car.Make} Module: {car.Model}");
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //TODO

            //X_Create a seperate class file called Car
            //X_Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //X_Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //X_The methods should take one string parameter: the respective noise property
            var lot = new CarLot();

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

            var car1 = new Car(2020, "Honda", "CRV", "BEEP!", "Puuuuuur", true);
            var car2 = new Car(1992, "Ford", "Focus", "BEEP!", "Rattle", true);
            var car3 = new Car(2020, "Volvo", "Volvo", "Woooo!", "silence...", false);

            lot.Cars.Add(car1);
            lot.Cars.Add(car2);
            lot.Cars.Add(car3);

            //Call each of the methods for each car

            car1.MakeEngineNoise();
            car2.MakeEngineNoise();
            car3.MakeEngineNoise();

            //*************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.Cars)
            {
                Console.WriteLine($"Year: {car.Year} Make: {car.Make } Model: {car.Model}");
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            //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
            CarLot busters = new CarLot();
            Car    gold    = new Car();

            gold.Year        = 2000;
            gold.Make        = "Lexus";
            gold.Model       = "GS300";
            gold.EngineNoise = "grrrrrr";
            gold.HonkNoise   = "honk";
            gold.IsDriveable = false;
            busters.Cars.Add(gold);

            Car blue = new Car(2014, "Chevy", "Spark", "djjjjjj", "Donk", true);

            busters.Cars.Add(blue);

            Car mocha = new Car()
            {
                Year = 2020, Make = "Lexus", Model = "LS500", EngineNoise = "drrrrr", HonkNoise = "Honk", IsDriveable = true
            };

            busters.Cars.Add(mocha);

            //*************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
            Console.WriteLine("Cars At Buster's Car Lot:");
            foreach (Car c in busters.Cars)
            {
                Console.WriteLine($"{c.Year} {c.Make} {c.Model}");
                Console.WriteLine();
            }
            Console.ReadLine();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var lot = new CarLot();

            var carOne = new Car();

            carOne.Year        = 2008;
            carOne.Make        = "Nissan";
            carOne.Model       = "Maxima";
            carOne.EngineNoise = "Vroom";
            carOne.HonkNoise   = "Maaaaah";
            carOne.IsDriveable = true;

            lot.Cars.Add(carOne);

            var carTwo = new Car()
            {
                Year        = 2012,
                Make        = "Ford",
                Model       = "Fusion",
                EngineNoise = "Whirr",
                HonkNoise   = "Meep",
                IsDriveable = true,
            };

            lot.Cars.Add(carTwo);

            var carThree = new Car(2005, "Mazda", "Three", "Nil", "Also Nil", false);

            lot.Cars.Add(carThree);

            carOne.MakeEngineNoise(carOne.EngineNoise);
            carTwo.MakeEngineNoise(carTwo.EngineNoise);
            carThree.MakeEngineNoise(carThree.EngineNoise);

            foreach (var vehicle in lot.Cars)
            {
                Console.WriteLine($"Year: {vehicle.Year} Make: {vehicle.Make} Model: {vehicle.Model}");
            }
        }
Exemplo n.º 5
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}");
        }
Exemplo n.º 6
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} ");
            }
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            var lot = new CarLot();

            Car car1 = new Car();

            car1.Year        = 2017;
            car1.Make        = "Chrysler";
            car1.Model       = "Pacifica";
            car1.EngineNoise = "purr";
            car1.HonkNoise   = "beep";
            car1.IsDriveable = true;

            lot.Cars.Add(car1);

            Car car2 = new Car()
            {
                Year        = 1968,
                Make        = "Chevy",
                Model       = "Cruiser",
                EngineNoise = "dead",
                HonkNoise   = "what noise?",
                IsDriveable = false
            };

            lot.Cars.Add(car2);

            Car car3 = new Car(2020, "Tesla", "Model S", "**ninja**", "meeeep", true);

            lot.Cars.Add(car3);

            foreach (var car in lot.Cars)
            {
                Console.WriteLine($"Year:{car.Year} Make: {car.Make} Model: {car.Model}");
            }
        }
Exemplo n.º 8
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
        }
Exemplo n.º 9
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}.");
            }
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            //TODO

            //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

            //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();

            //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

            //Instantiate 1 (using Dot Notation)
            var myCar = new Car();

            myCar.Make        = "Nissan";
            myCar.Model       = "Rogue";
            myCar.Year        = 2010;
            myCar.EngineNoise = "vroom";

            myCar.HonkNoise   = "beep beep";
            myCar.IsDriveable = true;

            lot.Cars.Add(myCar);

            //Instaniation 2 (object initializer syntax)
            var joansCar = new Car()
            {
                Year        = 2019,
                Make        = "Hyundai",
                Model       = "Kona",
                EngineNoise = "...",
                HonkNoise   = "beep",
                IsDriveable = false
            };

            lot.Cars.Add(joansCar);

            //Instantiate 3 (using the contructor to allow parameter values to be placed inside properties)
            var mikesCar = new Car(2015, "Honda", "Civic", "vrooom", "meep meep", true);

            lot.Cars.Add(mikesCar);

            //Call methods

            myCar.MakeEngineNoise(myCar.EngineNoise);
            mikesCar.MakeEngineNoise(mikesCar.EngineNoise);
            joansCar.MakeEngineNoise(joansCar.EngineNoise);



            //*************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

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

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

            foreach (var car in lot.Cars)
            {
                Console.WriteLine($"{car.Year} {car.Make} {car.Model}.");
            }
        }
Exemplo n.º 11
0
        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
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            CarLot carLot = new CarLot();

            //TODO

            //Now that the Car class is created we can instanciate 3 new cars
            Console.WriteLine(CarLot._numberOfCars);

            //The long way
            Car car1 = new Car();

            Console.WriteLine(CarLot._numberOfCars);

            //Adding a new car to the carList
            carLot.CarList.Add(car1);

            car1.Year        = "2000";
            car1.Make        = "Toyota";
            car1.Model       = "Celica";
            car1.EngineNoise = "Vrrrrrroooooom";
            car1.HonkNoise   = "Honk Honk";
            car1.IsDrivable  = false;

            //Object Initializer Syntax
            var car2 = new Car()
            {
                Year        = "2016",
                Make        = "BMW",
                Model       = "328i",
                EngineNoise = "Toot Toot",
                HonkNoise   = "Beep Beep",
                IsDrivable  = true
            };

            Console.WriteLine(CarLot._numberOfCars);
            carLot.CarList.Add(car2);

            //Parameterized Constructor
            Car car3 = new Car("2015", "Mercedes", "G Wagon", "prrrrrrr", "durk durk", true);

            Console.WriteLine(CarLot._numberOfCars);
            carLot.CarList.Add(car3);

            // DONE Set the properties for each of the cars
            // DONE Call each of the methods for each car

            //Console.WriteLine("Car 1");
            //car1.MakeEngineNoise(car1.EngineNoise);
            //car1.MakeHonkNoise(car1.HonkNoise);
            //Console.WriteLine();

            //Console.WriteLine("Car 2");
            //car2.MakeEngineNoise(car2.EngineNoise);
            //car2.MakeHonkNoise(car2.HonkNoise);
            //Console.WriteLine();

            //Console.WriteLine("Car 3");
            //car3.MakeEngineNoise(car3.EngineNoise);
            //car3.MakeHonkNoise(car3.HonkNoise);

            foreach (Car car in carLot.CarList)
            {
                Console.WriteLine($"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

            //*************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
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            //TODO
            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

            var v1 = new Car();

            v1.Year        = 2019;
            v1.Make        = "Ford";
            v1.Model       = "Ranger";
            v1.EngineNoise = "pop pop";
            v1.HonkNoise   = "get out the way";
            v1.IsDriveable = true;

            lot.Cars.Add(v1);

            var a2 = new Car();

            a2.Year        = 3090;
            a2.Make        = "Tesla";
            a2.Model       = "Model x";
            a2.EngineNoise = "Shhhh!";
            a2.HonkNoise   = "energize";
            a2.IsDriveable = true;

            lot.Cars.Add(a2);

            var b1 = new Car();

            b1.Year        = 1969;
            b1.Make        = "Chevy";
            b1.Model       = "Corvette";
            b1.EngineNoise = "Vroom";
            b1.HonkNoise   = "beep beep";
            b1.IsDriveable = false;

            lot.Cars.Add(b1);

            var z3 = new Car()
            {
                Year        = 2020,
                Make        = "BMW",
                Model       = "z3",
                EngineNoise = "swoosh",
                HonkNoise   = "meep",
                IsDriveable = true
            };

            lot.Cars.Add(z3);

            var q4 = new Car(2012, "GMC", "2500", "brumm", "boom", true);

            lot.Cars.Add(q4);

            v1.MakeEngineNoise(v1.EngineNoise);
            a2.MakeEngineNoise(a2.EngineNoise);
            b1.MakeEngineNoise(b1.EngineNoise);
            z3.MakeEngineNoise(z3.EngineNoise);
            q4.MakeEngineNoise(q4.EngineNoise);

            v1.MakeHonkNoise(v1.HonkNoise);
            a2.MakeHonkNoise(a2.HonkNoise);
            b1.MakeHonkNoise(b1.HonkNoise);
            z3.MakeHonkNoise(z3.HonkNoise);
            q4.MakeHonkNoise(q4.HonkNoise);

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

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


            //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
        }
Exemplo n.º 14
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}");
        }
Exemplo n.º 15
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}");
            }
        }
Exemplo n.º 16
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++}");
        }
Exemplo n.º 17
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
            //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

            //Instantiation 1
            CarLot lot = new CarLot();


            var myCar = new Car();

            lot.CarList.Add(myCar);

            myCar.Year        = 2021;
            myCar.Make        = "Jeep";
            myCar.Model       = "Jeep Wrangler Unlimited Sahara";
            myCar.EngineNoise = "vroom";
            myCar.HonkNoise   = "beep";
            myCar.IsDriveable = true;



            //Object Initializer

            var aguerCar = new Car()
            {
                Year        = 2022,
                Make        = "Telsa",
                Model       = "Cyber Truck",
                EngineNoise = "hoom",
                HonkNoise   = "boom",
                IsDriveable = true
            };

            lot.CarList.Add(aguerCar);


            // Constructor Initialization

            var akoiCar = new Car(2023, "Toyota", "Highlander", "kroom",
                                  "koom", true);

            lot.CarList.Add(akoiCar);


            // methods call
            myCar.MakeEngineNoise();
            akoiCar.MakeEngineNoise();
            aguerCar.MakeEngineNoise();

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

            foreach (var car in lot.CarList)
            {
                Console.WriteLine();
                Console.WriteLine($"Year: {car.Year} Make: {car.Make} and Model:{car.Model}");
            }
        }
Exemplo n.º 18
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

            var lot = new CarLot();

            //var list = new List<Car>();



            var camry = new Car();

            camry.Make        = "Toyota";
            camry.Model       = "Camry";
            camry.EngineNoise = "vroom";
            camry.Year        = 2015;
            camry.HonkNoise   = "beep";
            camry.IsDriveable = true;

            lot.Cars.Add(camry);



            var rinkucar = new Car()
            {
                Make        = "Tesla",
                Model       = "Cyber Truck",
                EngineNoise = "Ding",
                Year        = 2019,
                HonkNoise   = "song",
                IsDriveable = false
            };


            lot.Cars.Add(rinkucar);


            var akashCar = new Car(2013, "Nissan", "Rogue", "vroom", "varuga", false);



            lot.Cars.Add(akashCar);



            foreach (var car in lot.Cars)
            {
                Console.WriteLine($"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

            //*************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
        }
Exemplo n.º 19
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");
            }
        }
Exemplo n.º 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
        }
Exemplo n.º 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


            //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

            //Create a Motorcycle
            //Set the properties
            //Add the new motorcyle to the car lot list


            CarLot lot = new CarLot();

            var myCar = new Car(2020, "Honda", "Civic", "Noisy", "very loud", true);

            lot.Cars.Add(myCar);
            Console.WriteLine($"I own a {myCar.Year} {myCar.Make} {myCar.Model}");
            Console.WriteLine($"Its Horn is very {myCar.HonkNoise}, the engine is slightly {myCar.EngineNoise}");
            Console.WriteLine($"Its { myCar.IsDriveable} this car can be driven");
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();

            var alsoMyCar = new Car();

            lot.Cars.Add(alsoMyCar);
            alsoMyCar.Make        = "Chevrolet";
            alsoMyCar.Model       = "1500";
            alsoMyCar.Year        = 2013;
            alsoMyCar.HonkNoise   = "insert honk noise here";
            alsoMyCar.EngineNoise = "Vroom Vroom";
            alsoMyCar.IsDriveable = true;
            Console.WriteLine($"I own a {alsoMyCar.Year} {alsoMyCar.Make} {alsoMyCar.Model}.");
            Console.WriteLine($"Its { alsoMyCar.IsDriveable} that is can be driven although, the horn is very {alsoMyCar.HonkNoise}.");
            Console.WriteLine($"Side Note I love to hear the engine go {alsoMyCar.EngineNoise}");
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();


            var oldCar = new Car(2000, "Toyota", "Celica", "noisy", "honking", true);

            lot.Cars.Add(oldCar);
            Console.WriteLine($"I own a {oldCar.Year} {oldCar.Make} {oldCar.Model}");
            Console.WriteLine($"It is {oldCar.IsDriveable}, this car is driveable.");
            Console.WriteLine($"The engine is slightly {oldCar.EngineNoise}, but the {oldCar.HonkNoise} Function");
            Console.WriteLine("works correctly.");
            Console.WriteLine("Press enter to view amount of cars stored in the car lot currently.");
            Console.ReadLine();


            Motorcycle myMotorcycle = new Motorcycle(2, 3.6, 2020, "Yamaha", "Bolt");

            lot.Cars.Add(myMotorcycle);
            Console.WriteLine($"I own a {myMotorcycle.Year} {myMotorcycle.Make} {myMotorcycle.Model}");
            Console.WriteLine($"The current amount of cars in car lot : {CarLot.numberOfCars}");
        }
Exemplo n.º 22
0
        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("************************************");
            }
        }
Exemplo n.º 23
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)}");
        }
Exemplo n.º 24
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.

            var allisonsLot = new CarLot();



            //**COMPLETED** Create a seperate class file called Car
            //**COMPLETED** Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable - COMPLETED
            //**COMPLETED** 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
            var allisonsCar = new Car();

            //Set the properties for each of the cars

            //Using Dot Notation
            allisonsCar.Make        = "GMC";
            allisonsCar.Model       = "Terrain";
            allisonsCar.Year        = 2019;
            allisonsCar.EngineNoise = "vroom";
            allisonsCar.HonkNoise   = "beep";
            allisonsCar.IsDriveable = true;



            //Object Initializer Syntax
            var cipisCar = new Car()
            {
                Year        = 2014,
                Make        = "Nissan",
                Model       = "Rouge",
                EngineNoise = "...",
                HonkNoise   = "meow meow",
                IsDriveable = true
            };

            //Using the constructor to allow parameter values to be placed inside properties
            var dollysCar = new Car(2015, "Tesla", "Cyber Truck", "meeeeoow", "meow meow meow", true);


            allisonsLot.Cars.Add(allisonsCar);
            allisonsLot.Cars.Add(cipisCar);
            allisonsLot.Cars.Add(dollysCar);



            //Call each of the methods for each car
            allisonsCar.MakeEngineNoise(allisonsCar.EngineNoise);
            cipisCar.MakeEngineNoise(cipisCar.EngineNoise);
            dollysCar.MakeEngineNoise(dollysCar.EngineNoise);


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



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

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

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

            //**COMPLETED** Create a CarLot class
            //**COMPLETED** 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
        }
Exemplo n.º 25
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

            var carLot = new CarLot();

            // Standard Initializer
            var Car1 = new Car();

            Car1.Make        = "Chevrolet";
            Car1.Model       = "Classic";
            Car1.Year        = 2004;
            Car1.EngineNoise = "Zoom Zoom";
            Car1.HonkNoise   = "Beep Beep";
            Car1.IsDriveable = true;

            // Object Initializer
            var Car2 = new Car()
            {
                Make = "Nissan", Model = "Pathfinder", Year = 2001, EngineNoise = "Vroom", HonkNoise = "Beep", IsDriveable = true
            };

            var Car3 = new Car()
            {
                Make = "Toyota", Model = "Camry", Year = 1995, EngineNoise = "Clank Clunk", HonkNoise = "there is no horn noise", IsDriveable = false
            };

            //*************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.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();
                car.CarIsDriveable();
                Console.WriteLine("---------------------------");
            }
        }
Exemplo n.º 26
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");
            }
        }
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            //TODO
            var lot = new CarLot();



            //Create a seperate class file called Car



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

            reggiesCar.Make        = "Lexus";
            reggiesCar.Model       = "IS300";
            reggiesCar.Year        = 2019;
            reggiesCar.EngineNoise = "smooth";
            reggiesCar.HonkNoise   = "beep";
            reggiesCar.IsDrivable  = true;

            lot.Cars.Add(reggiesCar);



            var jonathansCar = new Car()
            {
                Year        = 2020,
                Make        = "BMW",
                Model       = "Series 3",
                EngineNoise = "rough",
                HonkNoise   = "honk",
                IsDrivable  = false
            };

            lot.Cars.Add(jonathansCar);


            var sylviosCar = new Car(2018, "Lexus", "GS300", "smooth", "beep", true);

            lot.Cars.Add(sylviosCar);


            reggiesCar.MakeEngineNoise();
            jonathansCar.MakeEngineNoise();
            sylviosCar.MakeEngineNoise();

            //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

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

            foreach (var car in lot.Cars)
            {
                Console.WriteLine($"Year: {car.Year} Make: {car.Make} Model: {car.Model}");
            }
        }
Exemplo n.º 28
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


            //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

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

            firstVehicle.Year        = 2015;
            firstVehicle.Make        = "Honda";
            firstVehicle.Model       = "Accord";
            firstVehicle.EngineNoise = "vroom";
            firstVehicle.HonkNoise   = "beep beep beep";
            firstVehicle.IsDriveable = true;


            //object initializer
            var secondVehicle = new Car()
            {
                Make        = "Toyota",
                Model       = "Corolla",
                Year        = 2016,
                EngineNoise = "vroom vroom",
                HonkNoise   = "beep beep",
                IsDriveable = true
            };

            //passing through constructor
            var thirdVehicle = new Car(2020, "Audi", "Q5", "vrrooom", "beeeep", true);

            //LIST
            var onLot = new CarLot();

            onLot.Cars.Add(firstVehicle);
            onLot.Cars.Add(secondVehicle);
            onLot.Cars.Add(thirdVehicle);

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

            foreach (Car vehicle in onLot.Cars)
            {
                Console.WriteLine($"{vehicle.Make} {vehicle.Model}, Made in the year {vehicle.Year}. It's engine goes {vehicle.EngineNoise} on the freeway, and when a car cuts them off, they go {vehicle.HonkNoise}. Definitely {vehicle.IsDriveable}, very reliable 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
        }
Exemplo n.º 29
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
        }
Exemplo n.º 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



            var car1 = new Car(2014, "Dodge", "Challenger", "Hummm", "Beep", true);

            //carvana.Cars.Add(car1);

            var car2 = new Car(2003, "Jeep", "Wrangler", "Vroom", "Beep Beep", true);

            //carvana.Cars.Add(car2);

            var car3 = new Car()

            {
                Year        = 2018,
                Make        = "Honda",
                Model       = "Accord 2.0t",
                EngineNoise = "Vroom",
                HonkNoise   = "Beep",
                IsDrivable  = true,
            };

            CarLot carvana = new CarLot();

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



            //carvana.Cars.Add(car1);
            //carvana.Cars.Add(car2);
            //carvana.Cars.Add(car3);



            //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

            Console.WriteLine($"Number of cars created: {carvana.Cars.Count}");

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


            foreach (var car in carvana.Cars)
            {
                Console.WriteLine(".............................");
                Console.WriteLine(car.Make);
                Console.WriteLine(car.Model);
                Console.WriteLine(car.Year);
                Console.WriteLine(car.EngineNoise);
                Console.WriteLine(car.HonkNoise);

                if (car.IsDrivable)
                {
                    Console.WriteLine("This car can drive");
                }
            }
        }