-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCar.cs
50 lines (46 loc) · 1.35 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
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PrototypePatternExample_ConsoleApp
{
public class Car : ICarPrototype
{
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, 5000)]
public int Year { get; set; }
public ICarPrototype Clone()
{
// Crea una create a new ins
return new Car
{
Id = this.Id,
Name = this.Name,
Model = this.Model,
Color = this.Color,
Brand = this.Brand,
Year = this.Year
};
}
public void PrintDetails()
{
Console.WriteLine($"Id: {Id}");
Console.WriteLine($"Name: {Name}");
Console.WriteLine($"Model: {Model}");
Console.WriteLine($"Color: {Color}");
Console.WriteLine($"Brand: {Brand}");
Console.WriteLine($"Year: {Year}");
Console.WriteLine();
}
}
}