---
title: "Bottle recycling machine state diagram"
subject: "Object Oriented Analysis and Design"
chapter: 2
key: "semester_6/object_oriented_analysis_and_design:bottle-recycling-state-diagram"
source: https://www.bctengineer.com/q/semester_6/object_oriented_analysis_and_design/bottle-recycling-state-diagram
site: BCT Engineering
---

# Bottle recycling machine state diagram

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

- Asked in: 2070 Bhadra, 8 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/object_oriented_analysis_and_design/bottle-recycling-state-diagram
- Whole chapter: https://www.bctengineer.com/md/semester_6/object_oriented_analysis_and_design/chapter-2

## Question

Bottle recycling machine has a control unit, bottle sensor, belt-unit, the sum counter, the end button and the receipt printer. There are at least states such as waiting, on run, on service and receipt printing. The "on run" state can be refined with sub-states working, blocked, failure notification, emptying. You can add few new states according to your own realization.
Draw a state diagram for the control unit.

## Short answer

Control unit states: Waiting (initial), On Run (composite with Working, Blocked, Failure Notification, Emptying sub-states), Receipt Printing, On Service. Transitions: bottleDetected starts On Run; jam moves to Blocked; timeout triggers Failure Notification; endPressed with sum>0 goes to Receipt Printing; serviceKey enters On Service; serviceFinished returns to Waiting.

## Answer

**Assumptions (extra states and events):** *Waiting* is the initial state; entering *Receipt Printing* totals the deposit before printing; a *Failure Notification* leads to *On Service*. Events: `bottleDetected`, `endPressed`, `jam`, `serviceKey`, `receiptPrinted`, `serviceFinished`.

#### State diagram of the control unit

```text
 (*)
  |
  v
 +--------------+   bottle detected    +------------------+
 |   Waiting    |--------------------->|      On Run      |
 | do/ monitor  |<---------------------|   (composite)    |
 |   sensor     |  timeout [sum = 0]   +------------------+
 +--------------+                        |             |
   ^  |     ^               end button   |             | from Failure
   |  |     |               [sum > 0]    |             | Notification /
   |  |     |                            v             v call service
   |  |     |              +------------------+  +--------------+
   |  |     +--------------| Receipt Printing |  |  On Service  |
   |  |   receipt printed  | entry/ total sum |  | do/ repair,  |
   |  |   / sum = 0        | do/ print        |  |  maintenance |
   |  |                    +------------------+  +--------------+
   |  |        service key                          |   ^
   |  +---------------------------------------------|---+
   +--------------- service finished ---------------+
```

#### Sub-states of "On Run"

```text
 +-----------------------------------------------------------+
 | On Run                                                    |
 |                                                           |
 |  (*)                                                      |
 |   |    bottle accepted / sum += value (self-transition)   |
 |   v                                                       |
 | +---------+     storage full      +----------+            |
 | | Working |---------------------->| Emptying |            |
 | |         |<----- emptied --------|          |            |
 | +---------+                       +----------+            |
 |   |     ^                                                 |
 |   | jam | cleared /                                       |
 |   | /   | restart belt                                    |
 |   | stop|                                                 |
 |   v belt|                                                 |
 | +---------+     timeout           +----------------------+|
 | | Blocked |---------------------->| Failure Notification ||
 | +---------+                       | entry/ raise alarm   ||
 |                                   +----------------------+|
 +-----------------------------------------------------------+
```

#### Transition table

| From | Event [guard] / action | To |
|---|---|---|
| Waiting | bottle detected | On Run (Working) |
| Working | bottle accepted / sum += value | Working |
| Working | jam detected / stop belt | Blocked |
| Blocked | cleared / restart belt | Working |
| Blocked | timeout > limit | Failure Notification |
| Working | storage full | Emptying |
| Emptying | emptied | Working |
| On Run | timeout [sum = 0] | Waiting |
| On Run | end button [sum > 0] | Receipt Printing |
| Receipt Printing | receipt printed / sum = 0 | Waiting |
| Waiting | service key | On Service |
| Failure Notification | call service | On Service |
| On Service | service finished | Waiting |

Entry/exit actions: entering *Receipt Printing* computes the total; leaving it resets the counter.

## Check yourself

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

1. What is the initial state of the control unit?
   A. Receipt Printing
   B. On Service
   C. Failure Notification
   D. Waiting
   Answer: D. The machine waits and monitors the sensor until a bottle is detected. (Key point: Initial state)

2. From Blocked, if the timeout exceeds the limit the unit goes to:
   A. Failure Notification
   B. Receipt Printing
   C. Working
   D. Waiting
   Answer: A. If the jam is not cleared in time, a failure is notified; if cleared, it returns to Working. (Key point: Blocked sub-state)

3. When the end button is pressed with sum > 0, the unit goes to:
   A. Waiting
   B. Emptying
   C. Receipt Printing
   D. On Service
   Answer: C. On Run moves to Receipt Printing, then back to Waiting with the sum reset. (Key point: End button)

4. Why is On Run a composite state?
   A. It is the final state
   B. It contains sub-states Working, Blocked, Failure Notification, Emptying
   C. It has no transitions
   D. It replaces Waiting
   Answer: B. The problem asks to refine On Run with sub-states. (Key point: Composite state)

## Related in Object Oriented Analysis and Design

- [Coffee vending machine use case diagram](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Acoffee-vending-machine-use-case) — Object Oriented Analysis and Design, chapter 2
- [Digital clock state diagram](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Adigital-clock-state-diagram) — Object Oriented Analysis and Design, chapter 2
- [Student course department class diagram](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Astudent-course-diagram-type) — Object Oriented Analysis and Design, chapter 2
- [Bus service use cases with elaboration](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Agre-bus-service-use-cases) — Object Oriented Analysis and Design, chapter 2
- [Video rental shop class diagram](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Avideo-rental-class-diagram) — Object Oriented Analysis and Design, chapter 2
- [Marina class diagram implementation code](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Amarina-class-diagram-implementation-code) — Object Oriented Analysis and Design, chapter 4

## Related in other subjects

- [Machine cycle, T-states, ANI 55H timing](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Amachine-cycle-tstate-ani-55h) — Microprocessor, chapter 2
- [ESL and replacement strategy for printing machines](https://www.bctengineer.com/question.md?key=semester_6%2Fengineering_economics%3Aprinting-machine-old-new-aec-esl) — Engineering Economics, chapter 5
- [Silver: states per unit volume vs atoms](https://www.bctengineer.com/question.md?key=semester_3%2Felectrical_engineering_material%3Asilver-states-per-volume) — Electrical Engineering Material, chapter 2, asked 2×
- [Centronics printer with 8255A in mode 1](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Acentronics-printer-8255-mode1) — Instrumentation II, chapter 2
