English · Dansk · Bahasa Melayu
OOP Coffee Machine
An object-oriented console coffee machine: order a drink, pay with US coins and get your coffee, a refund or change.
What is it?
Day 16 of the Udemy course 100 Days of Code: The Complete Python Pro Bootcamp. The coffee machine of day 15 is rebuilt with classes. A Menu lists the drinks and finds one by name, a CoffeeMaker holds the water, milk and coffee and makes the drink, and a MoneyMachine takes the coins, gives change and keeps the money earned. The machine serves espresso, latte and cappuccino. Type report to see the resources and the money in the machine, and off to switch it off.
What the exercise teaches
- Modelling a program with classes that each have one job: Menu, CoffeeMaker and MoneyMachine
- Keeping the assignment's class and method names
- Storing the menu, coins and starting resources in constants
- Writing automated pytest tests, and running a linter and a strict type checker
What it does
- Espresso, latte and cappuccino with their own ingredients and prices
- A check of water, milk and coffee before a drink is served
- Payment with quarters, dimes, nickels and pennies, with a refund or change
report shows the resources and the money earned; off switches the machine off
Next