-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
75 lines (65 loc) · 2.56 KB
/
Program.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
#region License
// Copyright (c) Angshuman Agarwal, All rights reserved.
// See License.txt in the project root for license information.
#endregion
using System;
namespace VendingMachine
{
class Program
{
static void Main(string[] args)
{
// Case : Machine is initialised with 1 quantity of each product. use the same instance throughout
var machine = new VendingMachineClient(1);
Scenario_1(machine);
// buy Coke again. This time error message should be displayed for 2 insert coins actions
Scenario_1(machine);
// user buys a Tango worth 163 P and inserts only 50P
// should get a message saying balance is remaining
Scenario_2(machine);
// user continues to buy Tango
Scenario_3(machine);
Console.ReadLine();
}
/// <summary>
/// Normal flow. User should get back change of 35P in an optimal way
/// </summary>
/// <param name="machine"></param>
private static void Scenario_1(IVendingMachineClient machine)
{
Console.WriteLine("**********Scenario 1**************\n");
machine.SelectProduct("Coke");
machine.InsertCoin(50);
machine.InsertCoin(50);
Console.WriteLine("\n**********END**************");
}
/// <summary>
/// User buys a costly item but inserts less money at first
/// </summary>
/// <param name="machine"></param>
private static void Scenario_2(IVendingMachineClient machine)
{
Console.WriteLine("**********Scenario 2**************\n");
machine.SelectProduct("Tango");
machine.InsertCoin(50);
Console.WriteLine("\n**********END**************");
}
/// <summary>
/// Continuing from Scenario 2, user inserts rest of the money and gets 7P back
/// Note that the user enters in 20Ps.
/// </summary>
/// <param name="machine"></param>
private static void Scenario_3(IVendingMachineClient machine)
{
Console.WriteLine("\n**********Scenario 3**************\n");
Console.WriteLine("...continuing from Scenario 2\n");
machine.InsertCoin(20);
machine.InsertCoin(20);
machine.InsertCoin(20);
machine.InsertCoin(20);
machine.InsertCoin(20);
machine.InsertCoin(20);
Console.WriteLine("\n**********END**************");
}
}
}