Compare commits
No commits in common. "d6d3111f517021891c7ae8a0a024b522b26c828e" and "34dac53f86d630df83a5c6ac5bc3b38f9c73fe4f" have entirely different histories.
d6d3111f51
...
34dac53f86
2
.idea/gradle.xml
generated
2
.idea/gradle.xml
generated
@ -9,10 +9,8 @@
|
|||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
<option value="$PROJECT_DIR$/clients" />
|
<option value="$PROJECT_DIR$/clients" />
|
||||||
<option value="$PROJECT_DIR$/common" />
|
|
||||||
<option value="$PROJECT_DIR$/module4" />
|
<option value="$PROJECT_DIR$/module4" />
|
||||||
<option value="$PROJECT_DIR$/module5" />
|
<option value="$PROJECT_DIR$/module5" />
|
||||||
<option value="$PROJECT_DIR$/module6" />
|
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
|
@ -14,9 +14,6 @@ dependencies {
|
|||||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||||
implementation project(':module4')
|
implementation project(':module4')
|
||||||
implementation project(':module5')
|
implementation project(':module5')
|
||||||
implementation project(':module6')
|
|
||||||
implementation project(':common')
|
|
||||||
testImplementation project(':common')
|
|
||||||
}
|
}
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.hithomelabs.clients.module5;
|
package com.hithomelabs.clients.module5;
|
||||||
|
|
||||||
import com.hithomelabs.princeton1.module5.Insertion;
|
import com.hithomelabs.princeton1.module5.Insertion;
|
||||||
import com.hithomelabs.princeton1.common.Apple;
|
import com.hithomelabs.princeton1.module5.Apple;
|
||||||
import com.hithomelabs.princeton1.common.Orange;
|
import com.hithomelabs.princeton1.module5.Orange;
|
||||||
|
|
||||||
public class InsertionClient {
|
public class InsertionClient {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.hithomelabs.clients.module5;
|
package com.hithomelabs.clients.module5;
|
||||||
|
|
||||||
import com.hithomelabs.princeton1.common.Apple;
|
import com.hithomelabs.princeton1.module5.Apple;
|
||||||
import com.hithomelabs.princeton1.module5.Shell;
|
import com.hithomelabs.princeton1.module5.Shell;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
package com.hithomelabs.clients.module6;
|
|
||||||
|
|
||||||
import com.hithomelabs.princeton1.common.Apple;
|
|
||||||
import com.hithomelabs.princeton1.module6.Merge;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class MergeClient {
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
int size = 100;
|
|
||||||
Apple[] apples = new Apple[size];
|
|
||||||
Merge<Apple> merge = new Merge<Apple>();
|
|
||||||
|
|
||||||
for (int i = 0; i < apples.length; i++) {
|
|
||||||
apples[i] = new Apple(new Random().nextInt(1000));
|
|
||||||
}
|
|
||||||
merge.sort(apples);
|
|
||||||
for (int i = 0; i < apples.length; i++)
|
|
||||||
System.out.println(apples[i]);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'java'
|
|
||||||
}
|
|
||||||
|
|
||||||
group = 'com.hithomelabs.princeton1.common'
|
|
||||||
version = 'unspecified'
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
testImplementation platform('org.junit:junit-bom:5.10.0')
|
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
|
||||||
}
|
|
||||||
|
|
||||||
java {
|
|
||||||
toolchain {
|
|
||||||
languageVersion = JavaLanguageVersion.of(11)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
@ -12,7 +12,6 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
testImplementation platform('org.junit:junit-bom:5.10.0')
|
testImplementation platform('org.junit:junit-bom:5.10.0')
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||||
testImplementation project(':common')
|
|
||||||
}
|
}
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.hithomelabs.princeton1.common;
|
package com.hithomelabs.princeton1.module5;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.hithomelabs.princeton1.common;
|
package com.hithomelabs.princeton1.module5;
|
||||||
|
|
||||||
public class Orange {
|
public class Orange {
|
||||||
private int size;
|
private int size;
|
@ -30,7 +30,7 @@ public class Shell<E> extends AbstractCustomSorts<E> {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Sample implementation of insertion sort as h-sort of h = 1
|
! sample implementation of insertion sort as h-sort of h = 1
|
||||||
* Will just be comparing the number of saps taken across both implementations
|
* Will just be comparing the number of saps taken across both implementations
|
||||||
*/
|
*/
|
||||||
public void insertionSort(E[] arr){
|
public void insertionSort(E[] arr){
|
||||||
|
@ -4,10 +4,12 @@ import org.junit.jupiter.api.AfterEach;
|
|||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import com.hithomelabs.princeton1.common.Apple;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
class SortTest {
|
class SortTest {
|
||||||
|
|
||||||
private ArrayList<Apple> apples;
|
private ArrayList<Apple> apples;
|
||||||
@ -24,7 +26,11 @@ class SortTest {
|
|||||||
private void testSort(AbstractCustomSorts<Apple> sortingAlgorithm) {
|
private void testSort(AbstractCustomSorts<Apple> sortingAlgorithm) {
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
apples.add(new Apple(random.nextInt(100)));
|
apples.add(new Apple(random.nextInt(100)));
|
||||||
|
Apple[] arr = apples.toArray(new Apple[apples.size()]);
|
||||||
|
apples.sort(null);
|
||||||
|
Apple[] sorted = apples.toArray(new Apple[apples.size()]);
|
||||||
|
sortingAlgorithm.sort(arr);
|
||||||
|
assertArrayEquals(sorted, arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -48,6 +54,7 @@ class SortTest {
|
|||||||
testSort(sortingAlgorithm);
|
testSort(sortingAlgorithm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void tearDown() {
|
void tearDown() {
|
||||||
sortingAlgorithm = null;
|
sortingAlgorithm = null;
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'java'
|
|
||||||
}
|
|
||||||
|
|
||||||
group = 'com.hithomelabs.princeton1.module6'
|
|
||||||
version = 'unspecified'
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
testImplementation platform('org.junit:junit-bom:5.10.0')
|
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
|
||||||
implementation project(':module5')
|
|
||||||
testImplementation project(':common')
|
|
||||||
}
|
|
||||||
java {
|
|
||||||
toolchain {
|
|
||||||
languageVersion = JavaLanguageVersion.of(11)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package com.hithomelabs.princeton1.module6;
|
|
||||||
|
|
||||||
import com.hithomelabs.princeton1.module5.AbstractCustomSorts;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class Merge<E> extends AbstractCustomSorts<E> {
|
|
||||||
@Override
|
|
||||||
public void sort(E[] arr) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
|||||||
package com.hithomelabs.princeton1.module6;
|
|
||||||
|
|
||||||
import com.hithomelabs.princeton1.module5.AbstractCustomSorts;
|
|
||||||
import com.hithomelabs.princeton1.common.Apple;
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.DisplayName;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
class MergeTest {
|
|
||||||
|
|
||||||
private AbstractCustomSorts<Apple> sortingAlgorithm;
|
|
||||||
private ArrayList<Apple> apples;
|
|
||||||
private Random random;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
apples = new ArrayList<>();
|
|
||||||
random = new Random();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@DisplayName("Merge Sort test client")
|
|
||||||
public void testSort(){
|
|
||||||
sortingAlgorithm = new Merge<Apple>();
|
|
||||||
for(int i = 0; i < 10; i++)
|
|
||||||
apples.add(new Apple(random.nextInt(100)));
|
|
||||||
Apple[] arr = apples.toArray(new Apple[apples.size()]);
|
|
||||||
apples.sort(null);
|
|
||||||
Apple[] sorted = apples.toArray(new Apple[apples.size()]);
|
|
||||||
sortingAlgorithm.sort(arr);
|
|
||||||
assertArrayEquals(sorted, arr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
sortingAlgorithm = null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,9 +11,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rootProject.name = 'Pricenton1'
|
rootProject.name = 'Pricenton1'
|
||||||
include 'module4'
|
include('module4')
|
||||||
include 'clients'
|
include 'clients'
|
||||||
include 'module5'
|
include 'module5'
|
||||||
include 'module6'
|
|
||||||
include 'common'
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user