Function in Class
This commit is contained in:
@@ -29,9 +29,9 @@ namespace CarManagerV2
|
||||
public static void removeCar(Car car)
|
||||
{
|
||||
cars = SafeManager.readCars("cars.csv");
|
||||
Console.WriteLine(cars);
|
||||
cars.Remove(car);
|
||||
Console.WriteLine(cars);
|
||||
Car existingCar = getCarById(car.Id);
|
||||
if (existingCar == null) return;
|
||||
cars.Remove(existingCar);
|
||||
SafeManager.saveCars("cars.csv", cars);
|
||||
}
|
||||
|
||||
@@ -47,12 +47,13 @@ namespace CarManagerV2
|
||||
}
|
||||
}
|
||||
|
||||
public static void createCar(string make, string model, int year, string color, int mileage, decimal price)
|
||||
public static Car createCar(string make, string model, int year, string color, int mileage, decimal price)
|
||||
{
|
||||
cars = SafeManager.readCars("cars.csv");
|
||||
int newId = cars.Count > 0 ? cars.Max(c => c.Id) + 1 : 1;
|
||||
Car newCar = new Car(newId, make, model, year, color, mileage, price);
|
||||
cars.Add(newCar);
|
||||
addCar(newCar);
|
||||
return newCar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user