---
title: "Coffee vending machine use case diagram"
subject: "Object Oriented Analysis and Design"
chapter: 2
key: "semester_6/object_oriented_analysis_and_design:coffee-vending-machine-use-case"
source: https://www.bctengineer.com/q/semester_6/object_oriented_analysis_and_design/coffee-vending-machine-use-case
site: BCT Engineering
---

# Coffee vending machine use case diagram

Object Oriented Analysis and Design · Chapter 2: Object Oriented Analysis

- Asked in: 2072 Asoj, 5 marks
- Video: [UML use case diagrams: Everything you need to know](https://www.youtube.com/watch?v=4emxjxonNRI) — Lucid Software
- Answer checked by Claude Sonnet 5.5 on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/object_oriented_analysis_and_design/coffee-vending-machine-use-case
- Whole chapter: https://www.bctengineer.com/md/semester_6/object_oriented_analysis_and_design/chapter-2

## Question

For the case study given below identify all the actors, use cases and relationships also draw use case diagram.
A coffee Vending Machine dispenses coffee to customers. Customers order coffee by selecting a recipe from a set of recipes. Customers pay for the coffee using coins. Change is given back if any to the customers. The Services staff loads ingredients (coffee powder, milk, sugar, water and chocolate) into the coffee machine. The service staff can also add a recipe by indicating the name of the coffee, the units of coffee powder, milk, sugar, water and chocolate to be added as well as the cost of the coffee.

## Short answer

Actors: Customer and Service Staff. Customer use cases: Order Coffee includes Select Recipe, Pay with Coins, Dispense Coffee; Give Change extends Pay with Coins. Service Staff use cases: Load Ingredients and Add Recipe.

## Answer

**Actors:** Customer and Service Staff (both are primary actors).

**Use cases**
- Customer: Order Coffee, which includes Select Recipe (choose a recipe from the set of recipes), Pay with Coins and Dispense Coffee. Give Change extends Pay with Coins.
- Service Staff: Load Ingredients (coffee powder, milk, sugar, water, chocolate) and Add Recipe (name of the coffee, units of each ingredient, cost).

**Relationships**
- `Order Coffee` **includes** `Select Recipe`, `Pay with Coins` and `Dispense Coffee`.
- `Give Change` **extends** `Pay with Coins`. It happens only if the money inserted is more than the cost.
- `Dispense Coffee` checks that enough ingredients are available.

```text
              +-----------------------------------+
              |   Coffee Vending Machine          |
              |                                   |
 [Customer] --|-( Order Coffee )                  |
              |    |include  |include  |include   |
              |    v         v         v          |
              |( Select  ( Pay with  ( Dispense   |
              |  Recipe ) Coins )     Coffee )    |
              |              ^                    |
              |              |extend              |
              |         ( Give Change )           |
              |                                   |
 [Service  ] -|-( Load Ingredients )              |
 [Staff    ] -|-( Add Recipe )                    |
              +-----------------------------------+
```

| Element | Type |
|---|---|
| Customer | Primary actor |
| Service Staff | Primary actor |
| Order Coffee, Select Recipe, Pay with Coins, Dispense Coffee, Give Change | Customer use cases |
| Load Ingredients, Add Recipe | Service staff use cases |
| include / extend | Relationships between the use cases above |

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which are the actors of the coffee vending machine?
   A. Coffee, Milk and Sugar
   B. Customer and Service Staff
   C. Recipe and Cost
   D. Only the Customer
   Answer: B. The external users are the Customer and the Service Staff; ingredients and recipes are data. (Key point: Actors)

2. Why is Give Change modelled as <<extend>> of Pay with Coins?
   A. Change is always given
   B. Payment cannot happen without it
   C. Change is given only if the money inserted exceeds the cost
   D. It is performed by the service staff
   Answer: C. It is conditional behaviour, which is what extend represents. (Key point: Give Change as extend)

3. Which use cases does Order Coffee include?
   A. Load Ingredients and Add Recipe
   B. Give Change only
   C. Update Cost
   D. Select Recipe and Pay with Coins (and Dispense Coffee)
   Answer: D. Ordering always involves selecting a recipe and paying, then dispensing, so these are included. (Key point: Order Coffee includes)

4. What are the service staff's use cases?
   A. Load Ingredients and Add Recipe
   B. Select Recipe and Pay
   C. Get Change
   D. Receive Coffee
   Answer: A. Staff load ingredients and add recipes (name, units of ingredients, cost). (Key point: Staff use cases)

## Related in Object Oriented Analysis and Design

- [External actors and library system sequence diagram](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Aexternal-actors-library-system-sequence-diagram) — Object Oriented Analysis and Design, chapter 2
- [XYZ Marina class diagram](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Amarina-class-diagram) — Object Oriented Analysis and Design, chapter 2
- [Math Training Institute use case diagram](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Amath-training-institute-use-case) — Object Oriented Analysis and Design, chapter 2
- [Collaboration and use case diagram case](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Apopulation-system-collaboration-usecase) — Object Oriented Analysis and Design, chapter 2
- [Importance of use case diagram](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Ause-case-diagram-importance-uml) — Object Oriented Analysis and Design, chapter 2
- [Four class relationships from figure](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Aclass-relationships-from-figure) — Object Oriented Analysis and Design, chapter 2

## Related in other subjects

- [Case study: feasibility, drawbacks, convincing](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Acs-2072kartik-feasibility) — Instrumentation II, chapter 10
- [Case study: new system vs existing (cost, manpower)](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Acs-cost-manpower-automation) — Instrumentation II, chapter 10, asked 4×
- [Case study: current control and recommendation](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Acs-existing-recommend-problems) — Instrumentation II, chapter 10, asked 3×
- [Case study: processing plants and improvement](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Acs-processing-plants) — Instrumentation II, chapter 10, asked 2×
