-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
201 lines (123 loc) · 5.78 KB
/
README
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
Barista-matic Programming Assignment
PROBLEM DESCRIPTION:
Your task is to create a simulator of an automatic coffee dispensing machine, called the Barista-matic. The machine maintains an inventory of drink ingredients, and is able to dispense a fixed set of possible drinks by combining these ingredients in different amounts. The cost of a drink is determined by its component ingredients.
Upon startup, the Barista-matic should display a list of its current inventory, followed by a menu to allow the user to select a drink. As drinks are dispensed, the inventory should be updated. Only drinks for which there is sufficient inventory can be dispensed.
The specified input and output formats for the Barista-matic must be followed exactly. At the end of these instructions, you will find examples of some input/output scenarios.
Your Barista-matic machine should be capable of dispensing the following drinks:
Drink Name
Ingredients
Coffee 3 units of coffee, 1 unit of sugar, 1 unit of cream
Decaf Coffee 3 units of Decaf Coffee, 1 unit of sugar, 1 unit of cream
Caffe Latte 2 units of espresso, 1 unit of steamed milk
Caffe Americano 3 units of espresso
Caffe Mocha 1 units of Espresso, 1 unit of cocoa, 1 unit of steamed milk, 1 unit of whipped cream
Cappuccino 2 units of Espresso, 1 unit of steamed milk, 1 unit of foamed milk
Per-unit ingredient costs are as follows:
Ingredient
Unit Cost
Coffee $0.75
Decaf Coffee
$0.75
Sugar
$0.25
Cream
$0.25
Steamed Milk
$0.35
Foamed Milk
$0.35
Espresso
$1.10
Cocoa
$0.90
Whipped Cream
$1.00
Initially the Barista-matic should contain 10 units of all ingredients, and restocking the machine should restore each ingredient to a maximum of 10 units.
INPUT FORMAT:
Your solution should read from the standard input stream, one command per line. No prompts or other extraneous user messages should be displayed. Blank input lines should be ignored.
Each valid command consists of a single character, as follows:
'R' or 'r' - restock the inventory and redisplay the menu
'Q' or 'q' - quit the application
[1-6] - order the drink with the corresponding number in the menu
If the user enters an invalid command, then the program should display a single-line message with the following format:
Invalid selection: <characters that were entered>
If the user selects a valid drink number, and the machine has the required ingredients to make the drink, then the program should display a single-line message with the following format:
Dispensing: <drink name>
On the other hand, if the drink order cannot be completed, then the program should display a single-line message with the following format:
Out of stock: <drink name>
The inventory and menu (see next section) should be displayed immediately following any applicable message.
OUTPUT FORMAT:
All output should be written to the standard output stream. At program startup, and following the processing of every command, the machine inventory and the drink menu should be displayed. Both the inventory list and the drink menu should be displayed in alphabetic order (by ingredient name or drink name, respectively), in the following format:
Inventory:
<ingredient name>,<quantity in inventory>
...
<ingredient name>,<quantity in inventory>
Menu:
<drink number>,<drink name>,<cost>,<in-stock>
...
<drink number>,<drink name>,<cost>,<in-stock>
Drinks should be numbered sequentially, starting at 1, in the order they are displayed in the menu. The in-stock indicator should be either "true" or "false".
Note: the sample output is indented in these instructions to make it easier to read. The output generated by your program should not have any whitespace at the beginning of a line.
TECHNICAL NOTES:
Your solution should be a command-line program written in Java, C# or VB.NET. If you use any external libraries in developing your solution (i.e. libraries that are not part of the standard Java or .NET platform) then you should bundle these libraries with your code so that we can run your solution.
It is not required that the initial machine configuration (inventory counts, available drinks and prices, etc.) be dynamic. In particular, it is acceptable to perform this initialization in code, rather than reading the configuration from an external file or database. However, your program should be flexible enough to allow new drinks to be added to the menu without requiring extensive code changes.
Make sure your program works correctly for all combinations of inputs. You may include automated tests if you like (using a framework such as JUnit or NUnit), but this is not required.
Extensive inline or method-level comments are not required, unless you want to include them to highlight particular aspects of your design or implementation.
EXAMPLE:
Upon application startup, the initial inventory list and drink menu would look like this:
Inventory:
Cocoa,10
Coffee,10
Cream,10
Decaf Coffee,10
Espresso,10
Foamed Milk,10
Steamed Milk,10
Sugar,10
Whipped Cream,10
Menu:
1,Caffe Americano,$3.30,true
2,Caffe Latte,$2.55,true
3,Caffe Mocha,$3.35,true
4,Cappuccino,$2.90,true
5,Coffee,$2.75,true
6,Decaf Coffee,$2.75,true
For input consisting of the following commands:
2
q
the program would produce the following output (including the startup output):
Inventory:
Cocoa,10
Coffee,10
Cream,10
Decaf Coffee,10
Espresso,10
Foamed Milk,10
Steamed Milk,10
Sugar,10
Whipped Cream,10
Menu:
1,Caffe Americano,$3.30,true
2,Caffe Latte,$2.55,true
3,Caffe Mocha,$3.35,true
4,Cappuccino,$2.90,true
5,Coffee,$2.75,true
6,Decaf Coffee,$2.75,true
Dispensing: Caffe Latte
Inventory:
Cocoa,10
Coffee,10
Cream,10
Decaf Coffee,10
Espresso,8
Foamed Milk,10
Steamed Milk,9
Sugar,10
Whipped Cream,10
Menu:
1,Caffe Americano,$3.30,true
2,Caffe Latte,$2.55,true
3,Caffe Mocha,$3.35,true
4,Cappuccino,$2.90,true
5,Coffee,$2.75,true
6,Decaf Coffee,$2.75,true