Question: java programming Write a Thermostat class such that a user of the Thermostat class can create an object of ThermoStat and set it to the

 java programming Write a Thermostat class such that a user of

the Thermostat class can create an object of ThermoStat and set it

java programming

Write a Thermostat class such that a user of the Thermostat class can create an object of ThermoStat and set it to the desired temperature within a pre-specified range. If the user tries set the temperature outside this range it should throw a TemperatureTooHigh or TemperatureTooLow exception. Use inheritance to create an exception superclass TemperatureOutofRange and subclasses TemperatureTooHigh and TemperatureTooLow 3. Sample Tester code: Thermostat t new ThermoStat(0, 100); t.setTemp(50); tsetTemp(150); t.setTemp(-50); l Should be OK Il Should throw TemperatureTooHigh exception. // Should throw TemperatureToolLow exception. Write a program to demonstrate throwing and catching of exceptions. Show that the catch specifying the superclass catches the subclass exceptions. The order of exception handlers is important. If you try to catch a superclass exception type before a subclass type, the compiler would generate crrors. Also show the re-throwing of exceptions. implement a priority queue capable of holding objects of an arbitrary type, T, by defining a Friorityoueue class that implements the queue with an Arraytist. A priority queue is a type of list where every item added to the queue also has an associated priority. Define priority in 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!