C++ Programming Ch.3 Exercise 4 Solution
Problem: CoffeeMachine ํด๋์ค๋ฅผ ๋ง๋ค์ด๋ณด์. main() ํจ์์ Execution Result๊ฐ ๋ค์๊ณผ ๊ฐ๋๋ก CoffeeMachine ํด๋์ค๋ฅผ ์์ฑํ๋ผ. ์์คํ๋ ์ ํ ์์๋ ์ปคํผ์ ๋ฌผ์ด ๊ฐ๊ฐ 1์ฉ ์๋น๋๊ณ , ์๋ฉ๋ฆฌ์นด๋ ธ์ ๊ฒฝ์ฐ ์ปคํผ๋ 1, ๋ฌผ์ 2๊ฐ ์๋น๋๊ณ , ์คํ ์ปคํผ๋ ์ปคํผ 1, ๋ฌผ 2, ์คํ 1์ด ์๋น๋๋ค. CoffeeMachine ํด๋์ค์๋ ์ด๋ค ๋ฉค๋ฒ ๋ณ์์ ์ด๋ค ๋ฉค๋ฒ ํจ์๊ฐ ํ์ํ์ง ์ ํ๋จํ์ฌ ์์ฑํ๋ผ. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #include using namespace std; int main() { CoffeeMachine java(5, 10, 3); // ์ปคํผ๋:5, ๋ฌผ๋:10, ์คํ:6 ์ผ๋ก ์ด๊ธฐํ java.drinkEspresso(); // ์ปคํผ 1, ๋ฌผ 1 ์๋น java.show(); // ํ์ฌ ์ปคํผ ๋จธ์ ์ ์ํ ์ถ๋ ฅ java.drinkAmericano(); // ์ปคํผ 1, ๋ฌผ 2 ์๋น java.show(); // ํ์ฌ ์ปคํผ ๋จธ์ ์ ์ํ ์ถ๋ ฅ java.drinkSugarCoffee(); // ์ปคํผ 1, ๋ฌผ 2, ์คํ 1 ์๋น java.show(); // ํ์ฌ ์ปคํผ ๋จธ์ ์ ์ํ ์ถ๋ ฅ java.fill(); // ์ปคํผ 10, ๋ฌผ 10, ์คํ 10 ์ผ๋ก ์ฑ์ฐ๊ธฐ java.show(); // ํ์ฌ ์ปคํผ ๋จธ์ ์ ์ํ ์ถ๋ ฅ Execution Result: ...