forked from BcnCarlos/CoffeMachine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrinkmaker.js
37 lines (28 loc) · 998 Bytes
/
drinkmaker.js
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
// Defining Drinkmaker class with a string for type of drink and a number for quantity of sugar.
class Drinkmaker{
constructor(string, num ){
this.type = string;
this.sugar = num || 0;
this.stick = 0;
}
// Make drink method that returns message with the drink selected, sugar, and stick. Sends error
makedrink(){
if (this.sugar > 0) this.stick = 1;
switch (this.type){
case "T":
return `M: Making Tea with ${this.sugar} sugars and ${this.stick} stick` ;
break;
case "H":
return `M: Making Chocolate with ${this.sugar} sugars and ${this.stick} stick`;
break;
case "C":
return `M: Making Coffee with ${this.sugar} sugars and ${this.stick} stick`;
break;
default:
return "M: Please enter, 'T' for tea, 'C' for coffee, or 'H' for chocolate";
}
}
}
if (typeof module !== 'undefined') {
module.exports = Drinkmaker;
}