Java Reference
In-Depth Information
7 Constructing Shapes through Inheritance and Aggregation
(continued)
5. Modify the TestCircle.java program as shown in Figure 10-65 to test your
classes until they are error-free. Properly document your solution. Print a
copy of the source code and submit all documents to your instructor.
FIGURE 10-65
J ava 2
J ava 2
v 5 . 0
v 5 . 0
8 Using the Enhanced for() with an Array
Rewrite PolyTest from Programming Assignment 3 (see Figure 10-61b) to
incorporate use of the enhanced for() loop to iterate through an array. The same
code also should work with Programming Assignment 4.
J ava 2
v 5 . 0
J ava 2
v 5 . 0
9 Creating and Using an Enum class
Rewrite Programming Exercise 5 such that it uses a new enum class,
AlarmStatus, which defines serial values of NORMAL, ACTIVATED, and
FAILURE. Use these values instead of the constants defined in the SecurityAlarm
class as shown in Figure 10-63a. Modify other classes, including FinalTest, as
necessary. Use the AlarmStatus returned from the method sensorSample() in a
switch statement to display when the system is normal, is activated, has failed, or
has an unknown status.
 
Search WWH ::




Custom Search