-
Notifications
You must be signed in to change notification settings - Fork 0
/
Company.cs
81 lines (64 loc) · 1.87 KB
/
Company.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
69
70
71
72
73
74
75
76
77
78
79
using System;
namespace FactoryMethod
{
abstract public class Company
{
public Company() { }
abstract public Application CreateApplication();
}
public class MobileDeveloper: Company
{
public MobileDeveloper() { }
public override Application CreateApplication()
{
MobileApp app = new MobileApp("Swift", "Wordz", MobileOS.iOS);
return app;
}
}
public class WebDeveloper : Company
{
public WebDeveloper() { }
public override Application CreateApplication()
{
WebApp app = new WebApp("Safari", "Wordz");
return app;
}
}
abstract public class Application
{
public string Platform { get; private set; }
public string ApplicationName { get; private set; }
public Application(string platform, string name)
{
this.Platform = platform;
this.ApplicationName = name;
}
abstract public void OpenApplication();
}
public enum MobileOS
{
iOS,
Android
}
public class MobileApp: Application
{
public MobileOS typeOS { get; private set; }
public MobileApp(string platform, string name, MobileOS typeOS): base(platform, name)
{
this.typeOS = typeOS;
}
public override void OpenApplication()
{
Console.WriteLine($"\nMobile app with {this.typeOS.ToString()}\n{this.Platform}\n{this.ApplicationName}");
}
}
public class WebApp : Application
{
public MobileOS typeOS { get; private set; }
public WebApp(string platform, string name) : base(platform, name) { }
public override void OpenApplication()
{
Console.WriteLine($"\nWeb app opened! \n{this.Platform}\n{this.ApplicationName}");
}
}
}