-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoffee.java
More file actions
73 lines (61 loc) · 1.97 KB
/
Copy pathCoffee.java
File metadata and controls
73 lines (61 loc) · 1.97 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package cafeCheckout;
import java.util.Scanner;
/**
* This Coffee class is the sub class of TimsOrder and implements the consumable
*
* @author Meet Patel
**/
public class Coffee extends TimsProduct implements Consumable {
// description of the product
private String description;
// calorie of the coffee
private int calorieCount;
// set all the properties of the coffee
private Coffee(String name, String description, double cost, double price, int calories) {
super(name, cost, price);
this.description = description;
this.calorieCount = calories;
}
// creates an object of Coffee
public static Coffee create() {
System.out.println(
"Please select your choice: \n" +
"1. Hot Chocolate \n" +
"2. French Vanila \n" +
"Your choice: "
);
// TODO: Fill in this stub to have a dialog with the user
Scanner sc = new Scanner(System.in);
int choice;
choice = sc.nextInt();
if(choice == 1) {
return new Coffee("Hot Chocolate", "Taste of Chocolate", 1.99, 4.99, 180);
}
else if(choice == 2) {
return new Coffee("French Vanila", "Taste of french Vanila", 1.59, 4.59, 170);
}
else {
System.out.println("Please choose correct option");
return null;
}
}
// return the description
public String getDescription() {
return description;
}
// return the calorie count
@Override
public int getCalorieCount() {
return calorieCount;
}
// return the consumption
@Override
public String getConsumptionMethod() {
return null;
}
// print the string
@Override
public String toString() {
return "Description: " + description + " Calorie Count: " + calorieCount;
}
}