Add project files.

This commit is contained in:
Frozd
2025-09-17 13:17:09 +02:00
parent 440e5a1b2b
commit 3561193b2f
22 changed files with 18541 additions and 0 deletions

56
CarManagerV2/Car.cs Normal file
View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarManagerV2
{
public class Car
{
int id;
string make;
string model;
int year;
string color;
int mileage;
decimal price;
public Car(int id, string make, string model, int year, string color, int mileage, decimal price)
{
this.make = make;
this.model = model;
this.year = year;
this.color = color;
this.mileage = mileage;
this.price = price;
}
public int Id { get { return id; } set { id = value; } }
public string Make { get { return make; } set { make = value; } }
public string Model { get { return model; } set { model = value; } }
public int Year { get { return year; } set { year = value; } }
public string Color { get { return color; } set { color = value; } }
public int Mileage { get { return mileage; } set { mileage = value; } }
public decimal Price { get { return price; } set { price = value; } }
public override string ToString()
{
return $"{make} {model} ({year})";
}
public string toCsvString()
{
return $"{id};{make};{model};{year};{color};{mileage};{price}";
}
public static Car fromCsvString(string csv)
{
Console.WriteLine(csv);
string[] parts = csv.Split(';');
Console.WriteLine(parts.Length);
return new Car(int.Parse(parts[0]), parts[1], parts[2], int.Parse(parts[3]), parts[4], int.Parse(parts[5]), decimal.Parse(parts[6]));
}
}
}