Create the java source code files for the classes listed in


Problem

Create the Java source code files for the classes listed in the inheritance hierarchy displayed in Figure 10-63a. Create a new Java source code file and enter code for the FinalTest.java test program, as shown in Figure 10-63b on page 686. Compile all source code and execute the test program to obtain the output as displayed in Figure 10-63c on page 686. Perform the following steps to complete these tasks:

1. The abstract base class, Security Alarm, has three constant values used for the state of the alarm: no alarm, sensor failure, and activated alarm. One method, alarm Failure(), cannot be overridden by any subclass. The other two methods, alarm() and sensor Sample(), are abstract.

2. The class, Entry Alarm, inherits from Security Alarm and has a single constant value as a threshold. If the simulation of the alarm sensor exceeds the threshold, the entry alarm is triggered. An Entry Alarm does not fail; it either signals no alarm or it activates an alarm.

3. The class, Fire Alarm, inherits from Security Alarm and has two constant values. One indicates a maximum temperature threshold. If the simulation of the alarm sensor exceeds the threshold, the fire alarm is activated. The other constant indicates a temperature failure threshold, to prevent false alarms. If the simulation of the alarm sensor yields a temperature below this value, the fire alarm has malfunctioned. The source code for this class, FireAlarm.java, is located in the Chapter10 folder on the Student Data Disk.

4. The class, CO Alarm, inherits from Security Alarm and has two constant values. One indicates a maximum carbon monoxide threshold. If the simulation of the alarm sensor exceeds the threshold, the carbon monoxide alarm is activated. The other constant indicates a carbon monoxide failure threshold, to prevent false alarms. If the simulation of the alarm sensor yields a carbon monoxide level below this threshold, the carbon monoxide alarm has malfunctioned.

5. The sensor Sample() method is used to simulate alarm conditions by generating a random number value simulating a sensor reading. If the alarm is activated, this method calls the alarm() method. If the alarm fails, this method calls the alarm Failure() method. Compile all source code and execute the test program to obtain the output as displayed in Figure 10-63c on the next page.

 

1845_Figure 10-63a.jpg

1218_Figure 10-63b.jpg

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Create the java source code files for the classes listed in
Reference No:- TGS02732564

Expected delivery within 24 Hours