-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (50 loc) · 1.78 KB
/
Copy pathProgram.cs
File metadata and controls
57 lines (50 loc) · 1.78 KB
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
using System;
namespace FactoryPatternApp
{
class Program
{
static void Main(string[] args)
{
//Ask the user for the phone they wish to create
Console.WriteLine("What kind of phone do you want to create?");
string userPhone = Console.ReadLine();
//Choose the correct type of phone to create through the factory method that implements the ICallable interface
ICallable phone = PhoneFactory.GetPhone(userPhone);
phone.Build();
Console.ReadLine();
//***********Example of bad practice************//
//Console.WriteLine("What kind of phone do you want to create?");
//string userPhone = Console.ReadLine();
//if (userPhone.ToLower() == "android")
//{
// AndroidPhone android = new AndroidPhone();
// android.Build();
// Console.ReadLine();
//}
//else if (userPhone.ToLower() == "apple")
//{
// ApplePhone apple = new ApplePhone();
// apple.Build();
// Console.ReadLine();
//}
//else if (userPhone.ToLower() == "iphone")
//{
// ApplePhone apple = new ApplePhone();
// apple.Build();
// Console.ReadLine();
//}
//else if (userPhone.ToLower() == "google")
//{
// GooglePhone google = new GooglePhone();
// google.Build();
// Console.ReadLine();
//}
//else
//{
// AndroidPhone android = new AndroidPhone();
// android.Build();
// Console.ReadLine();
//}
}
}
}