Tirsvad cfb1248882
TirSystem/git-workflows: Release / release (push) Skipped
TirSystem/git-workflows: Sync GitHub mirror metadata / sync-metadata (push) Successful in 22s
TirSystem/git-workflows: Publish wiki / publish-wiki (push) Successful in 49s
TirSystem/git-workflows: Publish accepted milestones / publish (push) Successful in 44s
TirSystem/git-workflows: Validate / validate (push) Successful in 36s
TirSystem/git-workflows: OpenGrep / opengrep (push) Successful in 1m54s
CI / Checks (push) Successful in 48s
Merge pull request 'Bring the project to the framework baseline (MIL-004)' (#29) from mil-004-baseline into main
2026-11-15 11:51:34 +01:00
2026-11-15 18:46:33 +08:00
2026-10-06 11:49:49 +02:00

OOP Coffee Machine

An object-oriented coffee machine in Python, solved as an assignment of Udemy's 100 Days of Code: The Complete Python Pro Bootcamp. The program takes a drink order, checks that the ingredients are sufficient, takes coins, gives change and makes the drink. It has no runtime dependencies, so it is easy to read, run and compare with your own solution.

The classes and methods use the assignment's names:

Class Methods
Menu get_items, find_drink
CoffeeMaker report, is_resource_sufficient, make_coffee
MoneyMachine report, process_coins, make_payment

📚 Table of Contents

🧭 Overview

At the prompt you can type a drink name (espresso, latte or cappuccino), report to print the resources and the money in the machine, or off to stop.

Project layout

.
├── src/coffee_machine/   The program
│   ├── constants.py      Menu, resources, coins, commands and messages
│   ├── menu.py           Menu and MenuItem
│   ├── coffee_maker.py   CoffeeMaker
│   ├── money_machine.py  MoneyMachine
│   ├── main.py           The loop that keeps the machine running
│   └── __main__.py       Lets `python -m coffee_machine` start the program
├── tests/                pytest tests
├── docs/                 Project documents (business case, plan, milestones, reviews)
├── Doxyfile              Doxygen configuration
├── pyproject.toml        Project configuration
└── .gitea/workflows/     Continuous integration

📋 Requirements

  • Python 3.13 or newer.
  • venv and pip, which come with Python (on Debian they are separate packages).
  • Git, to clone the repository.
  • Optional: Doxygen to build the source documentation.

There are no runtime dependencies. pytest, ruff and mypy are installed only for development, through the dev extra.

🛠️ Setup

Clone the repository and change into it:

git clone https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/016-oop-coffee-machine.git
cd 016-oop-coffee-machine

Then create a local virtual environment named .venv, upgrade pip and install the project in it.

Windows powershell

python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

If PowerShell refuses to run the activation script, allow it for this window only with Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass.

Linux debian

sudo apt install python3 python3-venv python3-pip git
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

Debian 13 (trixie) ships Python 3.13. On an older release, install Python 3.13 first (for example with pyenv) and use it to create the .venv.

MacOS

brew install python@3.13 git
python3.13 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

To leave the virtual environment, run deactivate.

▶️ Run

With the virtual environment active:

python -m coffee_machine

The installed command does the same:

coffee-machine

Example session:

What would you like? (espresso/latte/cappuccino): latte
Please insert coins.
How many quarters?: 12
How many dimes?: 0
How many nickels?: 0
How many pennies?: 0
Here is $0.50 in change.
Here is your latte. Enjoy!
What would you like? (espresso/latte/cappuccino): off

Build the source documentation

The source uses Doxygen comments and the Doxyfile in the repository root. Install Doxygen (winget install DimitriVanHeesch.Doxygen on Windows, sudo apt install doxygen on Debian, brew install doxygen on MacOS), then run:

doxygen Doxyfile

The HTML documentation is written to docs/doxygen/html/; open index.html in a browser. The output folder is ignored by git.

🧪 Tests

With the virtual environment active:

python -m pytest

The linter and the strict type check that the project also uses:

ruff check .
mypy

Continuous integration

The workflow in .gitea/workflows/ci.yml runs on Gitea Actions on every push and pull request. It creates a virtual environment on Python 3.13, upgrades pip, installs the project with the dev extra and runs ruff check ., mypy and python -m pytest. GitHub does not read the .gitea folder, so a GitHub mirror does not run it.

📄 License

GNU Affero General Public License v3.0, see LICENSE.

📎 Appendix: Project documents

The documents a newcomer needs, in reading order.

Document What it tells you
Business Case Why the project exists, its scope and success criteria
Stakeholder Analysis Who is involved; the stakeholder IDs used for owners and reviewers
Project Plan The gateways and their schedule
Milestones One document per gateway: Go/No-Go criteria and tasks
Artifact registry Where each artifact type lives, the next version, the PO language and domain
Traceability matrix How the artifacts link and when each was last reviewed

S
Description
Object-oriented coffee machine in Python (Udemy 100 Days of Code assignment) with pytest tests and Doxygen docs. No runtime dependencies.
Readme AGPL-3.0
229 KiB
0 Stars 1 Watchers 0 Forks
Languages
Python 100%