Question: JAVA 5.a: Evaluate the following code sample (in terms of good design practice). The code is for a simple home heating system. The system is
JAVA

5.a: Evaluate the following code sample (in terms of good design practice). The code is for a simple home heating system. The system is turned on if the current temperature falls below some minimum value. It's then turned off again when it goes above the maximum value. The class is instantiated and started i.e. it runs in its own thread of execution. class Thermostat extends Thread private final int THERMOMETER Ox10 private final int HEATER Of7; private final int HEATER_ON - 0xl; private final int HEATER OFF 0; public void run0 while (true) while (read(THERMOMETER)> min) sleep(100) write(HEATER, HEATER ON; while (read(THERMOMETER) min) sleep(100) write(HEATER, HEATER ON; while (read(THERMOMETER)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
