#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
class Container{
int size;
public:
Container(){size =10;}
void allfill(){ size=10;}
void consume(){ size--;}
int getSize(){return size;}//현재의 크기 리턴
};
class CoffeeVendingMachine{
Container tong[3];
void fulfill();
void selectEspresso();
void selectAmericano();
void selectSugarCoffee();
void show();
public:
void run();
};
void CoffeeVendingMachine::fulfill(){
tong[0].allfill();
tong[1].allfill();
tong[2].allfill();
}
void CoffeeVendingMachine::selectEspresso(){
tong[0].consume();
tong[1].consume();
}
void CoffeeVendingMachine::selectAmericano(){
tong[0].consume();
tong[1].consume();
tong[1].consume();
}
void CoffeeVendingMachine::selectSugarCoffee(){
tong[0].consume();
tong[1].consume();
tong[1].consume();
tong[2].consume();
}
void CoffeeVendingMachine::show(){
cout << "커피 " << tong[0].getSize() << "물 " << tong[1].getSize() << "설탕 " <<tong[2].getSize() << endl;
}
void CoffeeVendingMachine::run(){
int num;
cout << "****** 커피자판기를 작동합니다. *******" << endl;
while(1){
cout << "메뉴를 눌러주세요(1:에스프레소, 2:아메리카노, 3:설탕커피, 4:잔량보기, 5:채우기)>>";
cin >> num ;
if( num == 1){
if(tong[0].getSize()<1 || tong[1].getSize()<1){
cout << "원료가 부족합니다.\n";
}
else {
cout << "에스프레소를 드세요.\n";
selectEspresso();
}
}
else if(num == 2){
if(tong[0].getSize()<1 || tong[1].getSize()<2){
cout << "원료가 부족합니다.\n";
}
else {
cout << "아메리카노를 드세요.\n";
selectAmericano();
}
}
else if(num == 3){
if(tong[0].getSize()<1 || tong[1].getSize()<2 || tong[2].getSize()<1){
cout << "원료가 부족합니다.\n";
}
else {
cout << "설탕커피를 드세요.\n";
selectSugarCoffee();
}
}
else if(num == 4){//잔량 보기
show();
}
else if(num == 5){//채우기
fulfill();
}
}
}
int main() {
CoffeeVendingMachine c;
c.run();
return 0;
}