feat: display car age
This commit is contained in:
@@ -19,6 +19,7 @@ namespace CarManagerV3
|
||||
private int mileage;
|
||||
private decimal price;
|
||||
private int order;
|
||||
private int age;
|
||||
|
||||
public int Id { get => id;
|
||||
set {
|
||||
@@ -46,9 +47,7 @@ namespace CarManagerV3
|
||||
public int Year { get => year;
|
||||
set
|
||||
{
|
||||
|
||||
if (value < 1886 || value > DateTime.Now.Year + 1) throw new ArgumentException("Year must be between 1886 and next year.");
|
||||
Console.WriteLine($"Updating year to {year}");
|
||||
year = value;
|
||||
}
|
||||
}
|
||||
@@ -79,6 +78,19 @@ namespace CarManagerV3
|
||||
|
||||
public int Order { get => order; set => order = value; }
|
||||
|
||||
public int Age { get => DateTime.Now.Year - year; }
|
||||
public string AgeString
|
||||
{
|
||||
get
|
||||
{
|
||||
int age = this.Age;
|
||||
if (age == 0) return "New";
|
||||
else if (age == 1) return "1 year";
|
||||
else if (age < 0) return "From the future!";
|
||||
else return $"{age} years";
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Make Id read-only CUID. Allows for better integrity, especially when merging.
|
||||
//TODO: Add buying price and automatic calculation of profit/loss with selling price suggestion.
|
||||
//TODO: Add Buying Date.
|
||||
|
||||
Reference in New Issue
Block a user