practice02.py - #연습문제 2 커피 자판기를 제어하는 프로그램이 아래와 같이 실행되도록 작성하시오#커피 물 설탕 중

practice02.py - #연습문제 2 커피 자판기를...

• 2

This preview shows page 1 - 2 out of 2 pages.

# 연습문제 2- 커피 자판기를 제어하는 프로그램이 아래와 같이 실행되도록 작성하시오 . # 커피 , , 설탕 중 잔량이 하나라도 부족해 커피를 제공할 수 없는 경우 ‘원료가 부족합니다 .’ 를 출력 class CoffeeMachine: # 커피머신 클래스 지정 def __init__(self,coffee,water,sugar): #__init__ 을 통해 초기화 self.coffee=coffee self.water=water self.sugar=sugar def menu1(self): # 메뉴 1 if self.coffee>=1 and self.water>=1: # 에스프레소 : 최소 물 1, 커피 1 이 남아있을때 만 동작하는 함수 self.coffee-=1 # 메뉴 1 선택후 동작이 되면 물 , 커피 각각 1 씩 감소 self.water-=1 else: print(" 원료가 부족합니다 .") def menu2(self): # 메뉴 2 if self.coffee>=1 and self.water>=2: # 아메리카노 : 최소 물 2 커피 1 이 남아있을때 동작 self.coffee-=1 # 메뉴 2 선택후 동작이 되면 물 2, 커피 1 씩 감소 self.water-=2 else: print(" 원료가 부족합니다 .") def menu3(self): # 메뉴 3 if self.coffee>=1 and self.water>=2 and self.sugar>=1: #

• Summer '17

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern