-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoffeeShopOrder
More file actions
83 lines (67 loc) · 2.62 KB
/
Copy pathcoffeeShopOrder
File metadata and controls
83 lines (67 loc) · 2.62 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
74
75
76
77
78
79
80
81
82
83
import java.util.Scanner;
class Order {
String orderName;
String drinkName;
double price;
boolean isIced;
char size;
boolean toGo;
Order(String orderName, String drinkName, double price, boolean isIced, char size, boolean toGo) {
this.orderName = orderName;
this.drinkName = drinkName;
this.price = price;
this.isIced = isIced;
this.size = size;
this.toGo = toGo;
}
public void printOrder() {
System.out.println("| ~ Coffee Shop Order ~ |");
System.out.println("--------------------------");
System.out.println("\nClient: " + this.orderName);
System.out.println("\nDrink: " + this.drinkName);
System.out.println("\nSize: " + this.size + " | Iced: " + (this.isIced ? "Yes" : "No"));
System.out.println("\nTo go: " + (this.toGo ? "Yes" : "No"));
System.out.println("\nTotal: $" + this.price);
System.out.println("--------------------------\n");
}
}
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
boolean nextCustomer = true;
while (nextCustomer) {
System.out.println("| ~ Coffee Shop ~ |");
System.out.print("Client Name: ");
String name = scanner.nextLine();
System.out.print("Drink Name: ");
String drink = scanner.nextLine();
System.out.print("Price: ");
double price = scanner.nextDouble();
System.out.print("Size (1|P, 2|M, 3|G): ");
int s = scanner.nextInt();
char size = (s == 1) ? 'P' : (s == 3 ? 'G' : 'M');
System.out.print("Iced (1|Yes, 2|No): ");
boolean iced = (scanner.nextInt() == 1);
System.out.print("To Go (1|Yes, 2|No): ");
boolean toGo = (scanner.nextInt() == 1);
System.out.println("\nConfirm order? (1|Yes, 2|Cancel)");
int confirm = scanner.nextInt();
scanner.nextLine();
System.out.println("--------------------------\n");
if (confirm == 1) {
Order clientOrder = new Order(name, drink, price, iced, size, toGo);
clientOrder.printOrder();
} else {
System.out.println("Order Canceled.");
}
System.out.print("Next customer? (1|Yes, 2|Exit): ");
int resp = scanner.nextInt();
scanner.nextLine();
if (resp != 1) {
nextCustomer = false;
}
}
System.out.println("System Closed.");
scanner.close();
}
}