-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
48 lines (45 loc) · 1.52 KB
/
Program.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
using System;
using System.Linq;
namespace Factory
{
class Program
{
static void Main(string[] args)
{
// https://en.wikipedia.org/wiki/Factory_pattern
while (true)
{
Console.WriteLine("What car would you like to make?");
var i = 1;
foreach (var name in Enum.GetNames(typeof(ManufacturerEnum)).OrderBy(x => x))
{
Console.WriteLine("{0}. {1}", i, name);
i++;
}
var id = Console.ReadLine();
ManufacturerEnum manufacturer;
switch (id)
{
case "1":
manufacturer = ManufacturerEnum.Audi;
break;
case "2":
manufacturer = ManufacturerEnum.BMW;
break;
case "3":
manufacturer = ManufacturerEnum.Mercedes;
break;
case "4":
manufacturer = ManufacturerEnum.Volkswagen;
break;
default:
return;
}
var car = CarFactory.CreateCar(manufacturer);
Console.WriteLine();
Console.WriteLine("{0} {1}: {2} - {3} - {4}", car.Manufacturer, car.Model, car.Door, car.Tires, car.Engine);
Console.WriteLine();
}
}
}
}