# Unit 5 – Advanced Demo: Thermostat

This demo extends the basic Thermostat. The target temperature can now be
checked at any time, and two new indicators — whether the heating is
currently running and what mode the thermostat is in — update automatically
whenever the target changes.

## Setting up

1. Compile Thermostat.
2. Create `Thermostat("Living Room", 22.0)`.

## Experimenting

3. Right-click the thermostat on the Object Bench — the method menu now
   shows a getter for `targetTemperature`, and getters for `isHeating`
   and `modeLabel`.
4. Read `isHeating` — returns `true` because 22.0 is above 20.0.
5. Call `setTarget(18.0)`, then read `isHeating` and `modeLabel` again —
   both switch automatically.
6. Try `setTarget(50.0)` — `require` rejects the invalid value.

## What to look at in the code

7. `private set` on `targetTemperature` — the getter is public (so it
   appears in the method menu), but only code inside the class can write
   it. Compare with the basic demo, where the property had no getter in
   the method menu at all.
8. `val isHeating` with a custom getter — no value is stored; the
   expression reruns every time the property is read.
9. `val modeLabel` using `isHeating` — one computed property reading
   another; both stay in sync with `targetTemperature` automatically.
