-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathChocolateBoiler.cs
51 lines (44 loc) · 1.06 KB
/
ChocolateBoiler.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
namespace SingletonPattern;
public class ChocolateBoiler
{
private static readonly Lazy<ChocolateBoiler> Lazy = new(() => new ChocolateBoiler());
public static ChocolateBoiler Instance => Lazy.Value;
private ChocolateBoiler()
{
Empty = true;
Boiled = false;
}
private bool Empty { get; set; }
private bool Boiled { get; set; }
public void Fill()
{
if (!Empty)
{
Console.WriteLine();
return;
}
Empty = false;
Boiled = false;
Console.WriteLine("Fill the boiler with a milk/chocolate mixture.");
}
public void Drain()
{
if (Empty || !Boiled)
{
Console.WriteLine();
return;
}
Console.WriteLine("Drain the boiled milk and chocolate.");
Empty = true;
}
public void Boil()
{
if (Empty || Boiled)
{
Console.WriteLine();
return;
}
Console.WriteLine("Bring the contents to a boil.");
Boiled = true;
}
}