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

practice02.py - #연습문제 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: #
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

  • Summer '17

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors