Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions CarLotSimulatorApp/CarLotSimulator/Car.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
namespace CarLotSimulator
{
public class Car
{
public Car()
{

}
public Car(string year, string make, string model, string engineNoise, string honkNoise, bool isDriveable)
{
Year = year;
Make = make;
Model = model;
EngineNoise = engineNoise;
HonkNoise = honkNoise;
IsDriveable = isDriveable;


}

public string Year { get; set; }
public string Make { get; set; }
public string Model { get; set; }
public string EngineNoise { get; set; }
public string HonkNoise { get; set; }
public bool IsDriveable { get; set; }

public void MakeEngineNoise()
{
Console.WriteLine($"This car goes {EngineNoise}");
}
public void MakeHonkNoise()
{
Console.WriteLine($"This car goes {HonkNoise}");
}

}
}

14 changes: 14 additions & 0 deletions CarLotSimulatorApp/CarLotSimulator/CarLot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;


namespace CarLotSimulator
{
public class CarLot
{

public List<Car> ParkingLot = new List<Car>();


}
}
48 changes: 48 additions & 0 deletions CarLotSimulatorApp/CarLotSimulator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class Program
static void Main(string[] args)
{
//TODO
var carLot = new CarLot();


//Create a seperate class file called Car
//Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
Expand All @@ -18,16 +20,62 @@ static void Main(string[] args)
//Set the properties for each of the cars
//Call each of the methods for each car


Car myFirstCar = new Car("1999", "Pontiac", "Grand AM", "vroom!", "hooonk!", true);

Car mySecondCar = new Car("2002" , "Honda" , "CRV", "vrooom" , "honk" , true);

Car myThirdCar = new Car("2012" , "Toyota" , "RAV4", "vroom vroom" , "quack" , true);


carLot.ParkingLot.Add(myFirstCar);

carLot.ParkingLot.Add(mySecondCar);

carLot.ParkingLot.Add(myThirdCar);


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

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


Car myFourthCar = new Car("2000", "Nissan", "Ultima", "vroom" , "honk" , true);

Car myFifthCar = new Car();
myFifthCar.Year = "2003";
myFifthCar.Make = "Honda";
myFifthCar.Model = "Civic";
myFifthCar.EngineNoise = "Vroom Vroom";
myFifthCar.HonkNoise = "beep beep";
myFifthCar.IsDriveable = true;

carLot.ParkingLot.Add(myFourthCar);
carLot.ParkingLot.Add(myFifthCar);




Car mySixthCar = new Car() { Year = "1993", Make = "Toyota", Model = "Avalon", EngineNoise = "vrooom", HonkNoise = "broken", IsDriveable = false};
carLot.ParkingLot.Add(mySixthCar);

//*************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 carLot.ParkingLot)
{
Console.WriteLine($"{car.Year} {car.Make} {car.Model}");
car.MakeEngineNoise();
car.MakeHonkNoise();
Console.WriteLine();



}
}
}
}