Difference between revisions of "Comparator Assignment"

From CSE231 Wiki
Jump to navigation Jump to search
Line 10: Line 10:
 
=Code To Implement=
 
=Code To Implement=
 
==CompareUtils==
 
==CompareUtils==
 +
{{CodeToImplement|CompareUtils|min|compare.group}}
 +
 
===min===
 
===min===
 
  <nowiki>public static <E> Optional<E> min(E[] array, Comparator<E> comparator)</nowiki>
 
  <nowiki>public static <E> Optional<E> min(E[] array, Comparator<E> comparator)</nowiki>

Revision as of 13:51, 15 September 2022

Group Assignment

This is a group assignment.

Background

Comparator<T>

Optional<T>

HockeyPlayer

Code To Implement

CompareUtils

class: CompareUtils.java Java.png
methods: min
package: compare.group
source folder: student/src/main/java

min

public static <E> Optional<E> min(E[] array, Comparator<E> comparator)

CompareApps

closestTo

public static Optional<Integer> closestTo(Integer[] values, int target)

youngest

public static Optional<HockeyPlayer> youngest(HockeyPlayer[] players)

mostPoints

public static Optional<HockeyPlayer> mostPoints(HockeyPlayer[] players)