Due Tuesday, April 16, in class, on paper
Arrays
1. Problem 6, pg. 492
2. 18, pg. 493
3. 1, pg 496
Interfaces
4. In class we set up the Vehicle interface to capture the commonality of Automobile and Truck: they both provide getVIN() and getMake(). We briefly discussed the possibility of splitting this interface into two interfaces, one that captured the commonality of getVIN() and the other the commonality of getMake(). Let’s call the getVIN() interface IDed (not VINed as before, since that’s not proper English):
public
interface IDed {
String getVIN();
}
a. Show how to write Automobile.java and Truck.java so they implement IDed.
b. Create an array of IDed objects consisting of 2 Automobiles and 1 Truck, with your choice of properties.
c. Write a static method called findVIN that accepts a VIN and an array of IDed, and finds the first IDed object with that VIN and returns it, or null if it can’t be found.
ArrayLists of Strings: problems on pg. 674
5. Problem 2
6. 3
7. 4
8. 5
9. 7
10. 9
11. 10