10: Hashcodes

Submit this homework using Gradescope. You can type up your answers, or write legibly and scan them. Do not attempt to submit a paper copy in class, as it will not be accepted.


Suppose you have a BananaVendor class with the following instance variables, each of which must be considered when considering equality:

private int bananaCount;
private List<String> varieties;
private Banana banana;

A. (1 point) Write a valid equals method for the BananaVendor class.

B. (1 point) Write a valid hashCode method for the BananaVendor class. For full credit, your answer must both obey the hashCode contract as well as attempt to return distinct integers for distinct objects.

(Can you use Eclipse’s code generator? Sure. You’ll need to create a mock Banana class.)