Java Reference
In-Depth Information
Complete the method getEnumeration() so that it returns an anonymous inner
class that corresponds to the Enumeration interface for the names array in
NamesCollection . Then write a main method that creates a NamesCollection
object with a sample array of strings, retrieves the Enumeration for this class via
getEnumeration() , and then iterates through the enumeration outputting each
name using the getNext() method.
4. In Display 13.5, we described a sorting method to sort an array of type
Comparable[] . In Display 12.6, we described a sorting method that used the
merge sort algorithm to sort an array of type double[] into increasing order. Redo
the method in Display 12.6 so it applies to an array of type Comparable[] . Also,
do a suitable test program.
5. In Display 13.5 , we described a sorting method to sort an array of type Comparable[] .
In Display 12.8, we described a sorting method that used the quick sort
algorithm to sort an array of type double[] into increasing order. Redo the
method in Display 12.8 so it applies to an array of type Comparable[] . Also,
do a suitable test program.
6. Redo the class Person in Display 5.19 so that it implements the Cloneable
interface. This may require that you also redo the class Date so it implements the
Cloneable interface. Also, do a suitable test program.
7. Redo the class Person in Display 5.19 so that the class Date is a private inner class
of the class Person . Also, do a suitable test program. (You need not start from the
version produced in Programming Project 13.6. You can ignore Programming
Project 13.6 when you do this project.)
8. This is a combination of Programming Projects 13.6 and 13.7. Redo the class
Person in Display 5.19 so that the class Date is a private inner class of the class
Person , and so that the class Person implements the Cloneable interface. Also,
do a suitable test program.
9. Redo the class Employee and the class HourlyEmployee in Displays 7.2 and 7.3
so that the class Date is an inner class of the class Employee and an inherited inner
class of the class HourlyEmployee . Also, do a suitable test program.
10. Define an interface named Shape with a single method named area that calculates
the area of the geometric shape:
public double area();
Next, define a class named Circle that implements Shape . The Circle class should
have an instance variable for the radius, a constructor that sets the radius, accessor/
mutator methods for the radius, and an implementation of the area method. Also
define a class named Rectangle that implements Shape . The Rectangle class
should have instance variables for the height and width, a constructor that sets the
height and width, accessor and mutator methods for the height and width, and an
implementation of the area method.
Search WWH ::




Custom Search