-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoffe_machine.cpp
More file actions
129 lines (116 loc) · 2.86 KB
/
Copy pathcoffe_machine.cpp
File metadata and controls
129 lines (116 loc) · 2.86 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
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
#include<iostream>
using namespace std;
string coffe[1000]; //커피 이름, 가격, 메뉴는 전부 필요하니까 전역변수로 선언
int coffe_price[10], coffe_stock[10];
int coffe_s[10];
void coffe_set() { //커피의 이름/가격/재고/매출을 미리 설정한다.
coffe[1] = "아메리카노";
coffe[2] = "카페라떼";
coffe[3] = "바닐라라떼";
coffe[4] = "콜드브루";
coffe[5] = "허니자몽티";
coffe_price[1] = 3500;
coffe_price[2] = 3800;
coffe_price[3] = 4000;
coffe_price[4] = 3600;
coffe_price[5] = 4500;
for (int i = 1; i <= 5; i++) { //기본 재고는 10개로 한다.
coffe_stock[i] = 10;
coffe_s[i] = 0;
}
}
void manu_list() { //초기화면
cout << "=====================" << endl;
cout << " 메뉴 " << endl;
cout << "=====================" << endl;
cout << "1. 커피 주문하기" << endl;
cout << "2. 커피 매출 확인" << endl;
cout << "3. 커피 입고 하기" << endl;
cout << "4. 종료하기" << endl;
cout << "=====================" << endl;
}
void coffe_list() { //커피의 현황을 출력한다.
int i = 1;
while (coffe[i] != "") {
printf("%d.", i);
cout << coffe[i] << endl;
printf(" 가격:%d 재고:%d\n\n", coffe_price[i], coffe_stock[i]);
i++;
}
}
void coffe_order() {
int choice = 0, coffe_n; //choice : 커피를 선택, coffe_n : 커피의 개수
while (choice != 9) {
coffe_list();
cout << "구입하실 커피의 번호를 선택해주세요. (뒤로가시려면 9번을 누르세요.)" << endl;
cin >> choice;
if (choice == 9) {
break;
}
else if (coffe[choice] == "") {
cout << "해당되는 커피는 없습니다." << endl << endl;
continue;
}
cout << "몇개를 주문하시겠습니까?" << endl;
cin >> coffe_n;
while (coffe_stock[choice] < coffe_n) {
cout << "죄송합니다. 커피의 수량이 부족합니다. 수량을 조정해주세요" << endl;
cin >> coffe_n;
}
coffe_stock[choice] -= coffe_n; //커피의 재고 빼기
coffe_s[choice] += coffe_price[choice] * coffe_n; //커피의 매출 더하기
cout << "더 주문 하시겠습니까?" << endl;
}
return;
}
void coffe_sales() {
int total_sale = 0, i = 1;
while (coffe[i] != "") {
cout << coffe[i];
printf(" 매출 : %d\n", coffe_s[i]);
total_sale += coffe_s[i];
i++;
}
printf("총 매출 : %d\n", total_sale);
}
void coffe_plus() {
int choice = 0, coffe_n;
while (choice != 9) {
coffe_list();
cout << "입고하실 커피의 번호를 선택해주세요. (뒤로가시려면 9번을 누르세요.)" << endl;
cin >> choice;
if (choice == 9)
break;
else if (coffe[choice] == "") {
cout << "해당되는 커피는 없습니다." << endl << endl;
continue;
}
cout << "몇개를 입고하시겠습니까?" << endl;
cin >> coffe_n;
coffe_stock[choice] += coffe_n;
cout << "더 입고하시겠습니까?" << endl;
}
return;
}
int main() {
coffe_set(); //커피 리스트를 미리 셋팅한다.
int n = 0;
while (n != 4) {
manu_list();
cin >> n;
switch (n) {
case 1:
coffe_order();
break;
case 2:
coffe_sales();
break;
case 3:
coffe_plus();
break;
default:
break;
}
}
return 0;
}