Question
In our Abstract Classes and Interfaces lesson, we rewrote DataSetBook to take any object that implemented the Measurable interface. As several of you have noted,
In our Abstract Classes and Interfaces lesson, we rewrote DataSetBook to take any object that implemented the Measurable interface. As several of you have noted, a Boat may implement Measurable, a Book may implement Measurable, and a Building may implement Measurable, but mixing boats and books and buildings in the same data store makes little sense. Generics give the application writer compile-time help in keeping boats and buildings out of his book store. A Book and DataSetBook classes and a Measurable interface are provided, but feel free to rewrite them if that seems easier. You may also wish to start from a different version of DataSet; that's up to you. You are to write a generic class DataSetGeneric. DataSetGeneric should provide the usual add, size, getMin, getMax and toString methods. This should be a generic class so that only elements of the specified type are allowed into the data store. All of its elements should implement the Measurable interface, however; that's what you will rely on to implement getMin and getMax. Also provide a tester for DataSetGeneric.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started