Remember, the labs are not for credit, just for practice! But that means you have to do them to learn anything.

1. Modifying the examples

Download the example code I’ve given, and try making the following changes (there are also comments in the files as hints):

• In Ex08Pair:
• make an overload of cartesianToPolar that takes a Pair<Double> as its argument
• REUSE the code that is there
• don’t copy and paste the contents of cartesianToPolar!
• make range work for arrays of any type using a bounded type parameter
• check out Ex10TypeBounds for an example of a bounded type parameter
• In Ex09OrderedPair:
• make OrderedPair a generic class, like Pair
• again, you’ll have to bound the type parameter

2. Making and implementing a generic interface

1. Make a MyList<T> generic interface
• have a get method which takes an int and returns a T
• this gets the item at the given index
• have a set method which takes an int and a T
• this sets the item at the given index to the new value
• have a length method which returns an int
• this returns the length of the list
2. Make a DumbList<T> class which implements MyList<T>
• store the data internally as an array of T
• have the constructor take an int for the length of the List
• you’ll have to write (T[])new Object[length] to allocate the array of T
• implement the get, set, and length methods appropriately
3. Make a driver (a main) which tests your DumbList
• Use a couple different types (like DumbList<String> and something else)
• Check that it works!