Difference between revisions of "Optional Assignment"
Jump to navigation
Jump to search
(→Max) |
Peyton.gozon (talk | contribs) m (→Test) |
||
(One intermediate revision by the same user not shown) | |||
Line 3: | Line 3: | ||
=Code To Implement= | =Code To Implement= | ||
==Max== | ==Max== | ||
− | {{JavaToImplement|Max|max|optional. | + | {{JavaToImplement|Max|max|optional.exercise}} |
<nowiki>public static Optional<Integer> maximum(ImmutableList<Integer> xs)</nowiki> | <nowiki>public static Optional<Integer> maximum(ImmutableList<Integer> xs)</nowiki> | ||
Line 13: | Line 13: | ||
NOTE: in order to test this studio you must first complete the main (non-app) part of the [[ImmutableList_Assignment|ImmutableList<E> studio]]. | NOTE: in order to test this studio you must first complete the main (non-app) part of the [[ImmutableList_Assignment|ImmutableList<E> studio]]. | ||
− | {{TestSuite|MaxTestSuite|optional. | + | {{TestSuite|MaxTestSuite|optional.exercise}} |
Latest revision as of 05:12, 8 September 2022
Note this studio is required. It helps us gain experience using java.util.Optional<T>.
Code To Implement
Max
class: | Max.java | ![]() |
methods: | max | |
package: | optional.exercise | |
source folder: | src/main/java |
public static Optional<Integer> maximum(ImmutableList<Integer> xs)
Given a list of Integers, return Optional.of the maximum value in that list if it exists, otherwise return Optional.empty.
Test
NOTE: in order to test this studio you must first complete the main (non-app) part of the ImmutableList<E> studio.
class: | MaxTestSuite.java | ![]() |
package: | optional.exercise | |
source folder: | src/test/java |