Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement these comparable methods listed in white to pass the given test code. The test code should not be changed but all methods should be

Implement these comparable methods listed in white to pass the given test code. The test code should not be changed but all methods should be implemented and pass.
Project must compile, otherwise no grade.
JavaDoc for Main class (20 points)
Tests passing for MainTest class (hidden tests)(80 points)
Test class as follows: import java.util.Arrays;
public class Main
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
public class MainTest {
private Main intData1, intData2;
private Main doubleData1, doubleData2;
@BeforeEach
public void setUp(){
intData1= new Main>(new Integer[]{1,6,8,3,7,4,2,9,5});
intData2= new Main>(new Integer[]{2,4,3,1,5});
doubleData1= new Main>(new Double[]{1.2,6.7,8.3,3.5,7.4,4.9,2.1,9.6,5.8});
doubleData2= new Main>(new Double[]{2.4,4.3,3.5,1.1,5.5});
}
@Test
public void testMergeSort(){
testHelperMergeSort(intData1);
testHelperMergeSort(intData2);
testHelperMergeSort(doubleData1);
testHelperMergeSort(doubleData2);
}
private > void testHelperMergeSort(Main data){
T[] expected = Arrays.copyOf(data.data, data.data.length);
Arrays.sort(expected);
assertArrayEquals(expected, data.mergeSort(), "MergeSort did not sort correctly");
}
@Test
public void testQuickSort(){
testHelperQuickSort(intData1);
testHelperQuickSort(intData2);
testHelperQuickSort(doubleData1);
testHelperQuickSort(doubleData2);
}
private > void testHelperQuickSort(Main data){
T[] expected = Arrays.copyOf(data.data, data.data.length);
Arrays.sort(expected);
assertArrayEquals(expected, data.quickSort(), "QuickSort did not sort correctly");
}
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions

Question

Distinguish between geographic, volume, and time dispersion. LO6

Answered: 1 week ago

Question

Will the company help with relocation expenses?

Answered: 1 week ago