Question
@Test @Order(25) @Graded(description=testSubsetMaxP, marks=2.5) public void testSubsetMaxP() { assertEquals(0, aP.subsetMax(-1)); assertEquals(0, aP.subsetMax(4)); assertEquals(40, aP.subsetMax(0)); assertEquals(80, aP.subsetMax(1)); assertEquals(60, aP.subsetMax(2)); assertEquals(60, aP.subsetMax(3)); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); }
@Test @Order(25) @Graded(description="testSubsetMaxP", marks=2.5) public void testSubsetMaxP() { assertEquals(0, aP.subsetMax(-1)); assertEquals(0, aP.subsetMax(4)); assertEquals(40, aP.subsetMax(0)); assertEquals(80, aP.subsetMax(1)); assertEquals(60, aP.subsetMax(2)); assertEquals(60, aP.subsetMax(3)); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); }
@Test @Order(26) @Graded(description="testSubsetMaxCR", marks=2.5) public void testSubsetMaxCR() { testSubsetMaxP(); assertEquals(0, aCR.subsetMax(-1)); assertEquals(0, aCR.subsetMax(5)); assertEquals(10, aCR.subsetMax(0)); assertEquals(20, aCR.subsetMax(1)); assertEquals(60, aCR.subsetMax(2)); assertEquals(60, aCR.subsetMax(3)); assertEquals(-20, aCR.subsetMax(4));
currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); } @Test @Order(27) @Graded(description="testSubsetMaxD", marks=2.5) public void testSubsetMaxD() { testSubsetMaxCR(); int[] maxD = {10, 0, 60, -60, -20, -20, -20, -20, -20, -20}; for(int i=0; i < maxD.length; i++) { assertEquals(maxD[i], aD.subsetMax(i)); } for(int i=-100; i < 0; i++) { assertEquals(0, aD.subsetMax(i)); } for(int i=aD.data.length; i < aD.data.length + 100; i++) { assertEquals(0, aD.subsetMax(i)); } for(int i=-100; i<=100; i++) { assertEquals(0, aEmpty.subsetMax(i)); }
currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); } @Test @Order(28) @Graded(description="testSubsetMaxHD", marks=2.5) public void testSubsetMaxHD() { testSubsetMaxD(); int[] maxHD = {10, 0, 60, -60, -20, -20, -20, 0, 50, 30}; for(int i=0; i < maxHD.length; i++) { assertEquals(maxHD[i], aHD.subsetMax(i)); } for(int i=-100; i < 0; i++) { assertEquals(0, aHD.subsetMax(i)); } for(int i=aHD.data.length; i < aHD.data.length + 100; i++) { assertEquals(0, aHD.subsetMax(i)); } currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); } @Test @Order(29) @Graded(description="testMaxForRoundP", marks=2.5) public void testMaxForRoundP() { assertEquals(0, aP.maxForRound(-1)); assertEquals(0, aP.maxForRound(3)); assertEquals(60, aP.maxForRound(0)); assertEquals(60, aP.maxForRound(1)); assertEquals(80, aP.maxForRound(2)); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); } @Test @Order(30) @Graded(description="testMaxForRoundCR", marks=2.5) public void testMaxForRoundCR() { testMaxForRoundP(); assertEquals(0, aCR.maxForRound(-1)); assertEquals(0, aCR.maxForRound(3)); assertEquals(-10, aCR.maxForRound(0)); assertEquals(60, aCR.maxForRound(1)); assertEquals(60, aCR.maxForRound(2)); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); } @Test @Order(31) @Graded(description="testMaxForRoundD", marks=2.5) public void testMaxForRoundD() { testMaxForRoundCR(); assertEquals(0, aD.maxForRound(-1)); assertEquals(0, aD.maxForRound(5)); assertEquals(-10, aD.maxForRound(0)); assertEquals(60, aD.maxForRound(1)); assertEquals(-20, aD.maxForRound(2)); assertEquals(-20, aD.maxForRound(3)); assertEquals(-20, aD.maxForRound(4)); for(int i=-100; i<=100; i++) { assertEquals(0, aEmpty.maxForRound(i)); } currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); }
@Test @Order(32) @Graded(description="testMaxForRoundHD", marks=2.5) public void testMaxForRoundHD() { testMaxForRoundD(); assertEquals(0, aHD.maxForRound(-1)); assertEquals(0, aHD.maxForRound(5)); assertEquals(50, aHD.maxForRound(0)); assertEquals(60, aHD.maxForRound(1)); assertEquals(20, aHD.maxForRound(2)); assertEquals(-20, aHD.maxForRound(3)); assertEquals(-20, aHD.maxForRound(4)); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); }
@Test @Order(33) @Graded(description="testOverallMaxP", marks=2.5) public void testOverallMaxP() { assertEquals(80, aP.overallMax()); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); }
@Test @Order(34) @Graded(description="testOverallMaxCR", marks=2.5) public void testOverallMaxCR() { testOverallMaxP(); assertEquals(60, aCR.overallMax()); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); }
@Test @Order(35) @Graded(description="testOverallMaxD", marks=2.5) public void testOverallMaxD() { testOverallMaxCR(); assertEquals(60, aD.overallMax()); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); }
@Test @Order(36) @Graded(description="testOverallMaxHD", marks=2.5) public void testOverallMaxHD() { testOverallMaxD(); assertEquals(60, aHD.overallMax()); //yup, i should have chosen a more diverse data set currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); }
@Test @Order(37) @Graded(description="testMergeP", marks=2.5) public void testMergeP() { assertEquals("[30, 10, 40, 50, 20, 80, 10, 60, 30, 60, 60, 60]", Arrays.toString(aP.merge())); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); } @Test @Order(38) @Graded(description="testMergeCR", marks=2.5) public void testMergeCR() { testMergeP(); assertEquals("[-30, 10, -40, -50, 20, 0, -10, 60, 30, -60, 60, 60, -20, -20, -20]", Arrays.toString(aCR.merge())); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); } @Test @Order(39) @Graded(description="testMergeD", marks=2.5) public void testMergeD() { testMergeCR(); assertEquals("[-30, 10, -40, -10, 60, -60, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20]", Arrays.toString(aD.merge())); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); } @Test @Order(40) @Graded(description="testMergeHD", marks=2.5) public void testMergeHD() { testMergeD(); assertEquals("[-30, 10, -40, -10, 60, -60, -20, -20, -20, -20, -20, -20, -20, -20, 50, 10, 30, 20]", Arrays.toString(aHD.merge())); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); }
@AfterEach public void logSuccess() throws NoSuchMethodException, SecurityException { if(currentMethodName != null && !methodsPassed.contains(currentMethodName)) { methodsPassed.add(currentMethodName); Method method = getClass().getMethod(currentMethodName); Graded graded = method.getAnnotation(Graded.class); score+=graded.marks(); result+=graded.description()+" passed. Marks awarded: "+graded.marks()+" "; } } @AfterAll public static void wrapUp() throws IOException { if(result.length() != 0) { result = result.substring(0, result.length()-1); //remove the last " " } System.out.println(result+" Indicative mark: "+score); if(score==100) { System.out.println("Golazo! Golazo!!! Golazo!!!!!"); } } }
questions:
https://www.chegg.com/homework-help/questions-and-answers/functions-must-completed-using-instance-variable-array-data--s-array-arrays-integers-examp-q70141722?trackid=1QlJJkVA
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started