C++

명품 C++ 실습문제 3장 4번

Hs’s Coding vlog 2023. 1. 3. 18:56
#include <iostream>
#include <cstring>
using namespace std;

class Coffeemachine {

	int coffee=0, water=0, sugar=0;
public:
	Coffeemachine();
	Coffeemachine(int x, int y, int z);

	void drinkEsppresso();
	void drinkAmericano();
	void drinksugarcoffee();
	void show();
	void fill();

	

};
Coffeemachine::Coffeemachine() {
	coffee = 0, water = 0, sugar = 0;
}
Coffeemachine::Coffeemachine(int x ,int y,int z) {
	coffee = x; water = y; sugar = z;
	
}//생성자 구현완료!

void Coffeemachine::drinkEsppresso() {
	coffee = coffee - 1;
	water = water - 1;
	
}
void Coffeemachine::drinkAmericano() {
	coffee = coffee - 2;
	water = water - 1;
}
void Coffeemachine::drinksugarcoffee() {
	coffee = coffee - 1;
	water = water - 2;
	sugar = sugar - 1;
}
void Coffeemachine::show() {
	cout << "Status of Coffee Machine, " << "COFFEE:" << coffee << "\t" << "WATER: " << water << "\t" << "SUGAR:" << sugar << endl;
}
void Coffeemachine::fill() {
	coffee = 10;
	water = 10;
	sugar = 10;
}

int  main() {
	Coffeemachine java(5,10, 3);
	java.drinkEsppresso();
	java.show();
	java.drinkAmericano();
	java.show();
	java.drinksugarcoffee();
	java.show();
	java.fill();
	java.show();


}

'C++' 카테고리의 다른 글

명품 C++ 실습문제 3장 7번  (0) 2023.01.03
명품 C++ 실습문제 3장 6번  (0) 2023.01.03
명품 C++ 실습문제 3장 2번  (2) 2023.01.03
명품 C++ 실습문제 3장 1번  (0) 2023.01.03
명품 C++ 실습문제 2장 15번  (0) 2023.01.03