Suppose you are writing a program to manage shipments of bananas. You choose to represent the shipments as an object, using the following class definition:
public class BananaShipment {
final long serialNumber;
double weight;
String variety;
}
Each BananaShipment
is uniquely identified by its serialNumber
; the other instance variables are not guaranteed to be immutable or unique.
You realize you want your BananaShipment
objects to be able to participate in the Collections API; in particular, you’d like to to be able for it to work correctly and efficiently when creating sets of BananaShipment
s – either HashSet<BananaShipment>
or TreeSet<BananaShipment>
.
(3 points) Show the full class definition of BananaShipment
(including any required changes to the class declaration) that is required.