diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cbce1db --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.metadata/** +**/.metadata/** +**/.sonarlint/** +.sonarlint/** \ No newline at end of file diff --git a/Week8/EclipseIDE/Assignment8/.classpath b/Week8/Assignment8/.classpath similarity index 100% rename from Week8/EclipseIDE/Assignment8/.classpath rename to Week8/Assignment8/.classpath diff --git a/Week8/EclipseIDE/Assignment8/.project b/Week8/Assignment8/.project similarity index 100% rename from Week8/EclipseIDE/Assignment8/.project rename to Week8/Assignment8/.project diff --git a/Week8/EclipseIDE/Assignment8/.settings/org.eclipse.jdt.core.prefs b/Week8/Assignment8/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Week8/EclipseIDE/Assignment8/.settings/org.eclipse.jdt.core.prefs rename to Week8/Assignment8/.settings/org.eclipse.jdt.core.prefs diff --git a/Week8/EclipseIDE/Assignment8/bin/module-info.class b/Week8/Assignment8/bin/module-info.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/module-info.class rename to Week8/Assignment8/bin/module-info.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partA/IsReverse.class b/Week8/Assignment8/bin/partA/IsReverse.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partA/IsReverse.class rename to Week8/Assignment8/bin/partA/IsReverse.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partA/package-info.class b/Week8/Assignment8/bin/partA/package-info.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partA/package-info.class rename to Week8/Assignment8/bin/partA/package-info.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partB/Replace.class b/Week8/Assignment8/bin/partB/Replace.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partB/Replace.class rename to Week8/Assignment8/bin/partB/Replace.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partB/package-info.class b/Week8/Assignment8/bin/partB/package-info.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partB/package-info.class rename to Week8/Assignment8/bin/partB/package-info.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partC/CountNumbers.class b/Week8/Assignment8/bin/partC/CountNumbers.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partC/CountNumbers.class rename to Week8/Assignment8/bin/partC/CountNumbers.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partC/package-info.class b/Week8/Assignment8/bin/partC/package-info.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partC/package-info.class rename to Week8/Assignment8/bin/partC/package-info.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partD/InsertArray.class b/Week8/Assignment8/bin/partD/InsertArray.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partD/InsertArray.class rename to Week8/Assignment8/bin/partD/InsertArray.class diff --git a/Week8/EclipseIDE/Assignment8/bin/partD/package-info.class b/Week8/Assignment8/bin/partD/package-info.class similarity index 100% rename from Week8/EclipseIDE/Assignment8/bin/partD/package-info.class rename to Week8/Assignment8/bin/partD/package-info.class diff --git a/Week8/EclipseIDE/Assignment8/numbers.txt b/Week8/Assignment8/numbers.txt similarity index 100% rename from Week8/EclipseIDE/Assignment8/numbers.txt rename to Week8/Assignment8/numbers.txt diff --git a/Week8/EclipseIDE/Assignment8/src/module-info.java b/Week8/Assignment8/src/module-info.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/module-info.java rename to Week8/Assignment8/src/module-info.java diff --git a/Week8/EclipseIDE/Assignment8/src/partA/IsReverse.java b/Week8/Assignment8/src/partA/IsReverse.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/partA/IsReverse.java rename to Week8/Assignment8/src/partA/IsReverse.java diff --git a/Week8/EclipseIDE/Assignment8/src/partA/package-info.java b/Week8/Assignment8/src/partA/package-info.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/partA/package-info.java rename to Week8/Assignment8/src/partA/package-info.java diff --git a/Week8/EclipseIDE/Assignment8/src/partB/Replace.java b/Week8/Assignment8/src/partB/Replace.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/partB/Replace.java rename to Week8/Assignment8/src/partB/Replace.java diff --git a/Week8/EclipseIDE/Assignment8/src/partB/package-info.java b/Week8/Assignment8/src/partB/package-info.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/partB/package-info.java rename to Week8/Assignment8/src/partB/package-info.java diff --git a/Week8/JavaFiles/CountNumbers.java b/Week8/Assignment8/src/partC/CountNumbers.java similarity index 99% rename from Week8/JavaFiles/CountNumbers.java rename to Week8/Assignment8/src/partC/CountNumbers.java index bed8594..326d38e 100644 --- a/Week8/JavaFiles/CountNumbers.java +++ b/Week8/Assignment8/src/partC/CountNumbers.java @@ -1,4 +1,5 @@ //This code is written by Siwat Sirichai +package partC; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; diff --git a/Week8/EclipseIDE/Assignment8/src/partC/package-info.java b/Week8/Assignment8/src/partC/package-info.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/partC/package-info.java rename to Week8/Assignment8/src/partC/package-info.java diff --git a/Week8/EclipseIDE/Assignment8/src/partD/InsertArray.java b/Week8/Assignment8/src/partD/InsertArray.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/partD/InsertArray.java rename to Week8/Assignment8/src/partD/InsertArray.java diff --git a/Week8/EclipseIDE/Assignment8/src/partD/package-info.java b/Week8/Assignment8/src/partD/package-info.java similarity index 100% rename from Week8/EclipseIDE/Assignment8/src/partD/package-info.java rename to Week8/Assignment8/src/partD/package-info.java diff --git a/Week8/JavaFiles/CountNumbers.class b/Week8/JavaFiles/CountNumbers.class deleted file mode 100644 index ae66ed5..0000000 Binary files a/Week8/JavaFiles/CountNumbers.class and /dev/null differ diff --git a/Week8/JavaFiles/InsertArray.class b/Week8/JavaFiles/InsertArray.class deleted file mode 100644 index 481717f..0000000 Binary files a/Week8/JavaFiles/InsertArray.class and /dev/null differ diff --git a/Week8/JavaFiles/InsertArray.java b/Week8/JavaFiles/InsertArray.java deleted file mode 100644 index 9c8b3fc..0000000 --- a/Week8/JavaFiles/InsertArray.java +++ /dev/null @@ -1,58 +0,0 @@ -//This code is written by Siwat Sirichai -//Utilizing the method arraycopy(Array a,int a_start_pos, Array b,int b_start_pos, length) -//This is kinda complicated, diagram attached. -public class InsertArray { - public static void arraycopy(int[] a, int apos,int[] b, int bpos, int length) { - for(int i=0;i=a.length-1) { //If pos => a.length just put a before b - arraycopy(a, 0, result, 0, a.length); - arraycopy(b, 0, result, a.length, b.length); - } - else { - arraycopy(b, 0, result, pos, b.length); //put in b first - arraycopy(a, 0, result, 0, pos); //put the first part of a in (part before b) - arraycopy(a, pos, result, pos+b.length ,a.length-pos); //put the second part of a in (part after b) - } - return result; - } - - - public static void main(String[] args) { - // TODO Auto-generated method stub - int[] a = { 1, 2, 3, 4}; - int[] b = { 5, 6, 7}; - int[] c = { 8, 9, 10, 11, 12}; - - System.out.print("Printing array a: "); Replace.printArray(a); - System.out.print("Printing array b: "); Replace.printArray(b); - System.out.print("Printing array c: "); Replace.printArray(c); - - System.out.println("Now calling inserts!"); - System.out.println("------------------------"); - int[] d = insert(a,b,1); - int[] e = insert(a,b,4); //ERROR - int[] f = insert(b,a,0); - int[] g = insert(c,a,3); - int[] h = insert(c,a,-1); - int[] i = insert(c,a,7); //ERROR - - System.out.print("Printing array a, expecting {1,2,3,4} : "); Replace.printArray(a); - System.out.print("Printing array b, expecting {5,6,7} : "); Replace.printArray(b); - System.out.print("Printing array c, expecting {8,9,10,11,12} : "); Replace.printArray(c); - System.out.print("Printing array d, expecting {1,5,6,7,2,3,4} : "); Replace.printArray(d); - System.out.print("Printing array e, expecting {1,2,3,4,5,6,7} : "); Replace.printArray(e); - System.out.print("Printing array f, expecting {1,2,3,4,5,6,7}: "); Replace.printArray(f); - System.out.print("Printing array g, expecting {8,9,10,1,2,3,4,11,12} : "); Replace.printArray(g); - System.out.print("Printing array h, expecting {1,2,3,4,8,9,10,11,12} : "); Replace.printArray(h); - System.out.print("Printing array i, expecting {8,9,10,11,12,1,2,3,4} : "); Replace.printArray(i); - - } - -} diff --git a/Week8/JavaFiles/IsReverse.class b/Week8/JavaFiles/IsReverse.class deleted file mode 100644 index b918ab2..0000000 Binary files a/Week8/JavaFiles/IsReverse.class and /dev/null differ diff --git a/Week8/JavaFiles/IsReverse.java b/Week8/JavaFiles/IsReverse.java deleted file mode 100644 index 3cf02dc..0000000 --- a/Week8/JavaFiles/IsReverse.java +++ /dev/null @@ -1,35 +0,0 @@ -//This code is written by Siwat Sirichai -import java.util.Arrays; - -public class IsReverse { - - public static boolean isReverse(int[] a, int[] b) { - if (a==null&&b==null)return true; //Special Case #1: if a and b is null, result: true, return right away to prevent NullPointer exception. - if((a==null&&b!=null)||(a!=null&&b==null))return false; //Special Case #2: if only one of a or b is null, result: false, return right away to prevent NullPointer exception. - if (a.length != b.length)return false; //Special Case #3: if the length of a and b is not equal, result: false, return right away to prevent ArrayIndexoutofBound exception. - for(int i = 0;i