Test 1 Version A marking scheme Fields 1 / 1 -is there a field public static final int SIDES equal to 6? Constructors 0 / 1 -is there a private constructor? Methods -neededToRoll 0 / 1 -returns the correct value when (value % SIDES != -0)? 0 / 2 -returns the correct value when (value % SIDES == -0)? -median 1 / 1 -correctly throws the expected exception? 0 / 2 -returns the correct value when dice.size() is even? 2 / 2 -returns the correct value when dice.size() is odd? -isSorted 0 / 1 -is there a loop over the dice? 0 / 2 -in the loop body, are adjacent elements compared correctly? 0 / 1 -is the correct result returned? -isFullHouse 0 / 4 -is the correct value returned? -------------------- TA Comments: -every utility class has a private constructor -neededToRoll: See solutions for complete "neededToRoll" implemetation -median: your code does not work for lists of even size. -median: See solutions for complete "median" implemetation -isSorted: Using advanced for loop form does not work here. -isSorted: See solutions for complete "isSorted" implemetation -see solutions for complete "isFullHouse" implemetation -------------------- Unit tester output: YOUR SUMBISSION FAILED SOME UNIT TESTS Here is the test output: java -classpath .:/home/burton/work/teaching/2017F/2030/marking/secEtest1A/_jar/* org.junit.runner.JUnitCore test1.Test1Suite JUnit version 4.12 .E..E.E..E.E.E.E Time: 0.075 There were 7 failures: 1) test00(test1.DiceUtilTest) java.lang.AssertionError: found a non-private constructor 2) test02_neededToRoll(test1.DiceUtilTest) java.lang.AssertionError: neededToRoll(2) failed expected:<1> but was:<7> 3) test03_neededToRoll(test1.DiceUtilTest) java.lang.AssertionError: neededToRoll(6) failed expected:<1> but was:<31> 4) test05_median(test1.DiceUtilTest) java.lang.AssertionError: median([3, 4]) failed expected:<3> but was:<4> 5) test06_isSorted(test1.DiceUtilTest) java.lang.IndexOutOfBoundsException: Index: 3, Size: 1 6) test07_isFullHouse(test1.DiceUtilTest) java.lang.IndexOutOfBoundsException: Index: 5, Size: 5 7) test08_isFullHouse(test1.DiceUtilTest) java.lang.IndexOutOfBoundsException: Index: 5, Size: 5 FAILURES!!! Tests run: 9, Failures: 7 -------------------- Your submission: package test1; import java.util.ArrayList; // you may or may not need this import java.util.Collections; import java.util.List; /** * A utility class that provides methods related to 6-sided dice. * */ public class DiceUtil { public static final int SIDES = 6; public static int neededToRoll(int value) { int min = 1; if (value > 0) { for (int i = 1; i < value; i++) { min += 6; } } return min; } public static int median(List<Integer> dice) { if (dice.size() == 0) { throw new IllegalArgumentException(); } int n = dice.size() / 2; int median = dice.get(n); return median; } public static boolean isSorted(List<Integer> dice) { for (Integer d : dice) { if (dice.get(d) <= dice.get(d + 1)) { return true; } else { return false; } } return true; } public static boolean isFullHouse(List<Integer> dice) { // consider using Collections.sort List<Integer> Two = new ArrayList(); List<Integer> Three = new ArrayList(); List<Integer> Five = new ArrayList(); for (Integer d : dice) { Collections.sort(dice); if (dice.get(d) == dice.get(d + 2)){ Three.add(d); } if (dice.get(d) == dice.get(d + 1)) { Two.add(d); } if (dice.get(d) == dice.get(d + 4)) { Five.add(d); } /* if (List<Integer> Three && List<Integer> Two) { return true; } if (List<Integer> Five) { return false; } */ } return true; } } -------------------- Written answers marking scheme A 0 / 2 is a suitable definition given? B 0.5 / 3 are the values for a, b, and c correct? C 0 / 1 does the method description closely match the solution? 2 / 2 do the @param, @return, and @throws documentation exactly match the solution? D 2 / 2 is there a correct test case and suitable explanation? 2 / 2 is there a second correct test case and suitable explanation? -------------------- TA Comments A: - Static means that the field belongs to the class (not to any particular object of the class). B: - value of "a" is "400a" not "400" - value of "b" shall be the address of the myString object not the string value - c is primative data type so c value is 5 C: - Description is missing -------------------- Your submission: A. The keyword static means B. a: 400 b: 800a c: abcabcabcabcabc C. /** * @param median the value of the die in the middle of the list. * @param dice a list of dice. * @throw IllegalArgumentException if the list of dice is empty. * @return the median value of the dice in the list. */ D. Input list: [] Expected result: IllegalArgumentException is thrown. explanation: Test if IllegalArgumentException will be thrown when the list of dice is empty. Input list: [1] Expected result: 1 explanation: Test when the size of dice is one. --------------------