Question: This interface will define methods that compare Pokemon based on their type, name, and id This interface also has the following instance methods: int compareByType(Pokemon
This interface will define methods that compare Pokemon based on their type, name, and id This interface also has the following instance methods:
- int compareByType(Pokemon other)
- This should first compare pokemon on their primaryType in ascending alphabetical order. If the primaryTypes are the same, then you must compare by secondary Type
- Therefore, you must return a positive number if the current this.primary Type is greater than other's primaryType, a negative number if this.primary Type is less than other's primaryType, and zero if they are equal. Same goes when comparing secondaryType.
- int compareByName(Pokemon other)
- This should first compare pokemon on their names in ascending alphabetical order.
- Therefore, you must return a positive number if the current this.name is greater than other's name, a negative number if this.name is less than other's name, and zero if they are equal.
- int compareByID(Pokemon other)
- This should first compare pokemon on their names in ascending numeric order.
- Therefore, you must return a positive number if the current this.id is greater than other's id, a negative number if this.id is less than other's id, and zero if they are equal.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
