-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCar.cs
68 lines (59 loc) · 1.74 KB
/
Car.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ParkingSpace
{
class Car
{
readonly int id;
public int Id
{
get { return id; }
} //обработка исключений(добавить)
double cash;
public double Cash
{
get { return cash; }
set { cash = value; }
} //Обработка исключений(добавить)
readonly CarType category;
public CarType Category
{
get { return category; }
} //Обработка исключений(добавить)
public Car(int id, double cash, string category)
{
this.id = id;
this.cash = cash;
object container = Enum.Parse(typeof(CarType), category);
this.category = (CarType)container;
}
public void AddCash()
{
Console.Write("Введите суму пополнения: ");
double cash = Convert.ToInt32(Console.ReadLine());
this.cash += cash;
}
public static void ShowTypeCar()
{
Array car = Enum.GetValues(typeof(CarType));
Array colorList = Enum.GetValues(typeof(ConsoleColor));
for(int i = 0; i < car.Length; i++)
{
Console.ForegroundColor = (ConsoleColor)colorList.GetValue(i+3);
Console.Write("[{0}] ", car.GetValue(i));
}
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Gray;
}
}
enum CarType
{
Passenger = 1,
Truck,
Bus,
Motorcycle
}
}