-
Notifications
You must be signed in to change notification settings - Fork 0
/
Car.cs
55 lines (46 loc) · 1.2 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
using System.ComponentModel.DataAnnotations;
namespace BridgePatternConsoleExample
{
public class Car
{
public int Id { get; set; }
[StringLength(150)]
public string Name { get; set; }
[StringLength(150)]
public string Model { get; set; }
[StringLength(150)]
public string Color { get; set; }
[StringLength(150)]
public string Brand { get; set; }
[Range(1950, int.MaxValue)]
public int Year { get; set; }
}
public interface ICar
{
void DisplayDetails();
}
public class BasicCar : ICar
{
private readonly Car _car;
public BasicCar(Car car)
{
_car = car;
}
public void DisplayDetails()
{
Console.WriteLine($"Basic Car Details: {_car.Brand} {_car.Model}, {_car.Year}");
}
}
public class DetailedCar : ICar
{
private readonly Car _car;
public DetailedCar(Car car)
{
_car = car;
}
public void DisplayDetails()
{
Console.WriteLine($"Detailed Car Details: {_car.Brand} {_car.Model}, {_car.Year}, {_car.Color}");
}
}
}