static void Main(string[] args) { var lot = new CarLot(); var myCar = new Car(); myCar.Year = 2017; myCar.Make = "Pathfinder"; myCar.Model = "Nissan"; myCar.EngineNoise = "Vroom"; myCar.HonkNoise = "Beep"; myCar.IsDriveable = true; lot.Cars.Add(myCar); var mySecondCar = new Car() { Year = 2013, Make = "Hyundai", Model = "Genesis", EngineNoise = "Hummmmm", HonkNoise = "Hoonnkk", IsDriveable = true }; lot.Cars.Add(mySecondCar); var myThirdCar = new Car(2018, "Nissan", "Sentra", "VroomVroom", "BeepBeep", true); myCar.MakeEngineNoise(myCar.EngineNoise); mySecondCar.MakeEngineNoise(mySecondCar.EngineNoise); myThirdCar.MakeEngineNoise(myThirdCar.EngineNoise); lot.Cars.Add(myThirdCar); foreach (var car in lot.Cars) { Console.WriteLine($"Year: {car.Year} Make: {car.Make} Model: {car.Model}"); } //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 }
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 }
static void Main(string[] args) { //TODO //Create a seperate class file called Car DONE //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 lot = new Carlot(); //Using Dot Notation Car fiat = new Car(); lot.CarList.Add(fiat); fiat.CarMake = "Fiat"; fiat.CarModel = "500 Abarth"; fiat.CarYear = 2015; fiat.EngineNoise = "Vroom"; fiat.Horn = "beep"; fiat.IsDrivable = true; //Object Initializer Syntax Car grandPrix = new Car() { CarYear = 2006, CarMake = "Pontiac", CarModel = "Grand Prix", EngineNoise = "Nyoom", Horn = "meepmeep", IsDrivable = false }; lot.CarList.Add(grandPrix); //Using the Constructor to allow parameter values to be placed inside properties. Car jeep = new Car(2018, "Jeep", "Cherokee", "vroom", "honkhonk", true); lot.CarList.Add(jeep); //Call Methods. fiat.MakeEngineNoise(fiat.EngineNoise); grandPrix.MakeEngineNoise(grandPrix.EngineNoise); jeep.MakeEngineNoise(jeep.EngineNoise); //*************BONUS*************// // Set the properties utilizing the 3 different ways we learned about, one way for each car //*************BONUS X 2*************// foreach (var car in lot.CarList) { Console.WriteLine(); Console.WriteLine($"Year: {car.CarYear} Make: {car.CarMake} and Model: {car.CarModel}"); } }
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?"); }
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}"); } }
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(); var oneFord = new Car(); oneFord.Make = "Ford"; oneFord.Model = " Explorer"; oneFord.Year = 2020; oneFord.EngineNoise = "vroom"; oneFord.HonkNoise = "beep"; oneFord.IsDrivable = true; lot.Cars.Add(oneFord); var twoKia = new Car(); twoKia.Make = "Kia"; twoKia.Model = "Sportage"; twoKia.Year = 2000; twoKia.EngineNoise = "sputter"; twoKia.HonkNoise = "none"; twoKia.IsDrivable = false; lot.Cars.Add(twoKia); var threeChevy = new Car() { Make = "Chevy", Model = "Blazer", Year = 2012, EngineNoise = "vroom", HonkNoise = "honk honk", IsDrivable = true, }; lot.Cars.Add(threeChevy); var fourMazda = new Car("Mazda", "Miata", 2018, "vroom", "beep", true); lot.Cars.Add(fourMazda); //Call Methods oneFord.MakeEngineNoise(oneFord.EngineNoise); twoKia.MakeEngineNoise(twoKia.EngineNoise); threeChevy.MakeEngineNoise(threeChevy.EngineNoise); fourMazda.MakeEngineNoise(fourMazda.EngineNoise); Console.WriteLine($"Number of cars: {CarLot.numberOfCars}"); foreach (var car in lot.Cars) { Console.WriteLine($" Year:{car.Year} Make:{car.Make} Model:{car.Model}"); } }
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 var bryansCar = new Car(); bryansCar.Make = "Honda"; bryansCar.Model = "Accord"; bryansCar.Year = 2004; bryansCar.EngineNoise = "V4"; bryansCar.HonkNoise = "High pitched beep"; bryansCar.IsDriveable = true; var katesCar = new Car() { Make = "Volkswagon", Model = "Tiguan", Year = 2008, EngineNoise = "V6", HonkNoise = "mid range beep", IsDriveable = false, }; var ericsCar = new Car(2018, "Honda", "Civic Type-R", "turbo V6", "mid range honk", true); //Set the properties for each of the cars //Call each of the methods for each car bryansCar.MakeEngineNoise(bryansCar.EngineNoise); katesCar.MakeEngineNoise(katesCar.EngineNoise); ericsCar.MakeEngineNoise(ericsCar.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 //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);
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) { 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 }
static void Main(string[] args) { //Done //dot notation var PhilsCar = new Car(); PhilsCar.Make = "Ford"; PhilsCar.Model = "Focus"; PhilsCar.Year = 2013; PhilsCar.EngineNoise = "vroom"; PhilsCar.HonkNoise = "beep"; PhilsCar.IsDriveable = true; //object initializer var LliversCar = new Car() { Year = 2019, Make = "Tesla", Model = "Cyber Truck", EngineNoise = "...", HonkNoise = "brmmp", IsDriveable = false }; //constructor allowing parameter values inside properties var LizsCar = new Car(2013, "Honda", "Civic", "vrrroom", "vruuuga", true); //call methods PhilsCar.MakeEngineNoise(PhilsCar.EngineNoise); LliversCar.MakeEngineNoise(LliversCar.EngineNoise); LizsCar.MakeEngineNoise(LizsCar.EngineNoise); //*************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}); //} }
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 }
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 }
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}"); } }
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}"); } }
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}"); } }
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 }
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}"); }
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} "); } }
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 //Done //Now that the Car class is created we can instanciate 3 new cars //Set the properties for each of the cars //Done //Call each of the methods for each car // //Instanciate the Carlot at the beginning of the program //and as you create a car add the car to the list. var myLot = new Carlot(); //First way to created a new instance, //using . notation //now can access the properties of the //Car class to work with the new instance var carA = new Car(); carA.Year = 1967; carA.Make = "Ford"; carA.Model = "Mustang"; carA.EngineNoise = "vroom"; carA.HonkNoise = "beep"; carA.IsDriveable = true; // Adding carA to local variable myLot we created for list of Cars // in the Carlot class // references travel from bigger container to smaller unit myLot.Cars.Add(carA); //object initializer syntax // - has scope, // properties are separated by a comma var carB = new Car() { Year = 2017, Make = "Honda", Model = "Civic", EngineNoise = "tut", HonkNoise = "beep", IsDriveable = false, }; //Adding carB myLot.Cars.Add(carB); //Construction Pass //will pass through the new constructor we made in Class.cs var carC = new Car(2020, "Tesla", "Whateveritscalled", "wrrrr", "beep", true); myLot.Cars.Add(carC); //Calling Methods //Instance Method //Parameters go through parenthesis, Methods go through methods, //Instances of a class go through instances of a class //The method has instructions to print to console carC.MakeEngineNoise(); carB.MakeEngineNoise(); carA.MakeEngineNoise(); //Using a foreach loop is for when you want to apply some factor to each //item in a list, array, etc?? //using the local variable car, i can write to console foreach (var car in myLot.Cars) { Console.WriteLine($"{car.Year} {car.Make} {car.Model}"); } //Done //*************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 }
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 }
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 }
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"); } }
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}"); } }
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}"); } }
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 }
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 }
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 }