-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (50 loc) · 1.81 KB
/
Program.cs
File metadata and controls
53 lines (50 loc) · 1.81 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
using DesignPatterns.Factory;
using DesignPatterns.Iterator;
using System;
namespace DesignPatterns
{
class Program
{
static void Main(string[] args)
{
//Change this value to mimic the behaviour of the corresponding pattern.
int designPat = 3;
switch (designPat)
{
case 1:
Console.WriteLine("Singleton Pattern");
Singleton.Singleton.InstanceVar.Foo();
Singleton.Singleton.InstanceVar.Foo();
break;
case 2:
Console.WriteLine("Iterator Pattern");
Person[] pArr = new Person[3]
{
new Person("John", "Doe"),
new Person("Will", "Smith"),
new Person("Wild", "Cats"),
};
People pList = new People(pArr);
foreach (Person p in pList)
{
Console.WriteLine("{0} {1}", p.FName, p.lName);
}
break;
case 3:
Console.WriteLine("Factory Pattern");
//val = 1 for rocket ship and 2 for space ship
int val = 2;
ShipFactory factoryObj = new ShipFactory();
Ship shipType = null;
//Create ship object
shipType = factoryObj.MakeShip(val);
//To display the type of ship and it's speed
shipType.ShipStatus();
break;
default:
break;
}
Console.ReadKey();
}
}
}