Difference between revisions of "Comparator Assignment"
Jump to navigation
Jump to search
m (→closestTo) |
|||
Line 19: | Line 19: | ||
===closestTo=== | ===closestTo=== | ||
+ | {{Warning | Attempt to do this by utilizing CompareUtils.min(). The purpose of this is to get practice using comparables. }} | ||
+ | |||
<nowiki>public static Optional<Integer> closestTo(Integer[] values, int target)</nowiki> | <nowiki>public static Optional<Integer> closestTo(Integer[] values, int target)</nowiki> | ||
+ | |||
+ | |||
+ | Return the index of the closest integer withing "values" to target. | ||
+ | |||
===youngest=== | ===youngest=== | ||
<nowiki>public static Optional<HockeyPlayer> youngest(HockeyPlayer[] players)</nowiki> | <nowiki>public static Optional<HockeyPlayer> youngest(HockeyPlayer[] players)</nowiki> |
Revision as of 19:45, 7 February 2023
Contents
Group Assignment
This is a group assignment.
Background
Code To Implement
CompareUtils
class: | CompareUtils.java | |
methods: | min | |
package: | compare.group | |
source folder: | student/src/main/java |
min
public static <E> Optional<E> min(E[] array, Comparator<E> comparator)
CompareApps
class: | CompareApps.java | |
methods: | closestTo youngest mostPoints |
|
package: | compare.group | |
source folder: | student/src/main/java |
closestTo
Warning: Attempt to do this by utilizing CompareUtils.min(). The purpose of this is to get practice using comparables. |
public static Optional<Integer> closestTo(Integer[] values, int target)
Return the index of the closest integer withing "values" to target.
youngest
public static Optional<HockeyPlayer> youngest(HockeyPlayer[] players)
mostPoints
public static Optional<HockeyPlayer> mostPoints(HockeyPlayer[] players)
Testing Your Solution
class: | _MinCompareTestSuite.java | |
package: | compare.group | |
source folder: | testing/src/test/java |