Homework 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 class with the following instance variables:

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

A. (1 point) Write a valid equals method.

B. (1 point) Write a valid hashCode method. 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. Note you’ll need to create a mock Banana class too.)