static void Main(string[] args)
Console.WriteLine("Welcome to your online car rental system, owner");
Console.WriteLine("Enter the number of cars that your company owns");
int.TryParse(Console.ReadLine(), out int numCars);
Car[] cars = new Car[numCars];
for (int i = 0; i < cars.Length; i++)
Console.WriteLine("Enter the number corresponding with the action you would like to perform or any other value to exit" +
"\n3: Takeout/Return Car" +
"\n4: Edit price or MPG" +
"\n5: Define a value that is currently in use");
int.TryParse(Console.ReadLine(), out int action);
Console.WriteLine("Make Model MPG rent price inUse Driver Name");
Console.WriteLine("-------------------------------------------------------------");
for (int i = 0; i < cars.Length; i++)
cars[i].listProperties();
Console.WriteLine("Enter the number of the car you would like to Takeout/Return: ");
bool success2 = int.TryParse(Console.ReadLine(), out int userChoice2);
if (success2 && userChoice2 > 0 && userChoice2 < (numCars + 1))
cars[userChoice2 - 1].checkoutOrReturnCar();
Console.WriteLine("Invalid Input");
Console.WriteLine("Enter the number of the car you would like to edit the values of: ");
bool success3 = int.TryParse(Console.ReadLine(), out int userChoice);
if (success3 && userChoice > 0 && userChoice < (numCars + 1))
cars[userChoice - 1].changeValues();
Console.WriteLine("Invalid Input");
Console.WriteLine("Exiting the program");
public static void defineCars(Car[] cars)
for(int i = 1;i <= cars.Length;i++)
Console.WriteLine($"Would you like to assign values to car {i}? Enter y or n");
string choice = Console.ReadLine();
Console.WriteLine($"Enter the make of car {i}");
string make = Console.ReadLine();
Console.WriteLine($"Enter the model of car {i}");
string model = Console.ReadLine();
Console.WriteLine($"Enter the MPG of car {i}");
double.TryParse(Console.ReadLine(), out double mpg);
Console.WriteLine($"Enter the daily rent price of car {i}");
double.TryParse(Console.ReadLine(), out double price);
cars[i-1] = new Car(price, mpg, make, model);
public static void defineCarsInUse(Car[] cars)
for (int i = 1; i <= cars.Length; i++)
Console.WriteLine($"Is car {i} in use? Enter y or n");
string choice = Console.ReadLine();
Console.WriteLine($"Enter the first name of the person currently using car {i}: ");
string firstName = Console.ReadLine();
Console.WriteLine($"Enter the last name of the person currently using car {i}: ");
string lastName = Console.ReadLine();
cars[i - 1] = new Car(firstName, lastName);
private string make { get; set; }
private string model { get; set; }
private string DriverFirst { get; set; }
private string DriverLast { get; set; }
private double pricePerDay;
if (value.GetType() == typeof(bool))
private double PricePerDay
if (pricePerDay.GetType() == typeof(double) || pricePerDay.GetType() == typeof(int))
if (value.GetType() == typeof(double) || value.GetType() == typeof(int))
if (MPG.GetType() == typeof(double) || MPG.GetType() == typeof(int))
if (value.GetType() == typeof(double) || value.GetType() == typeof(int))
public Car(string DriverFirst, string DriverLast)
this.DriverFirst = DriverFirst;
this.DriverLast = DriverLast;
public Car(double pricePerDay, double MPG, string make, string model)
this.pricePerDay = pricePerDay;
DriverFirst = "None"; DriverLast = "None";
pricePerDay = 0; MPG = 0;
make = "Insert"; model = "Insert";
DriverFirst = "None"; DriverLast = "None";
public void listProperties()
Console.WriteLine($"{make}{model,13}{MPG,6}{pricePerDay,10:C}{inUse,13}{DriverFirst, 6} {DriverLast}");
public void changeValues()
Console.WriteLine($"Enter the new MPG of this car");
double.TryParse(Console.ReadLine(), out double MPG);
Console.WriteLine($"Enter the new daily price to rent this car");
double.TryParse(Console.ReadLine(), out double price);
public void checkoutOrReturnCar()
Console.WriteLine("Is this car being checked-out or returned? Enter c or r: ");
string status = Console.ReadLine();
Console.WriteLine("Enter first name of the person taking out the car");
DriverFirst = Console.ReadLine();
Console.WriteLine("Enter last name of the person taking out the car");
DriverLast = Console.ReadLine();