forked from trashvin/Tutorial_UsingStateless
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
52 lines (44 loc) · 1.64 KB
/
Copy pathProgram.cs
File metadata and controls
52 lines (44 loc) · 1.64 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
using System;
namespace Lightswitch
{
class Program
{
static void Main(string[] args)
{
TraditionalLightSwitch mySwitch1 = new TraditionalLightSwitch("Traditional Switch",true,true);
StatelessLightSwitch stateSwitch = new StatelessLightSwitch("Stateless Switch",true,true);
Console.WriteLine("\n Toggling traditional switch at predefined time....\n");
StartSwitchAtDefinedTime(mySwitch1);
Console.WriteLine("\n Toggling stateless switch at predefined time...\n");
StartSwitchAtDefinedTime(stateSwitch);
Console.WriteLine("Graph >>>>>>>>>>>.");
Console.WriteLine(stateSwitch.ShowStateMachine());
Console.Read();
}
static void StartSwitchAtDefinedTime(ALightSwitch mySwitch)
{
TimeSpan[] times =
{
new TimeSpan(4,30,30),
new TimeSpan(9,45,0),
new TimeSpan(14,2,6),
new TimeSpan(19,21,34),
new TimeSpan(23,46,0)
};
foreach(var time in times)
{
Console.WriteLine("Toggling switch at " + time.ToString());
mySwitch.SetTimeOfDay(time);
mySwitch.ToggleSwitch();
}
}
static void StartSwitchNow(ALightSwitch mySwitch)
{
for (int i = 0; i < 3; i++ )
{
Console.WriteLine("Toggling switch now : "+ DateTime.Now.TimeOfDay.ToString());
mySwitch.ToggleSwitch();
}
}
}
}