diff --git a/Assignement12/.classpath b/Assignement12/.classpath
deleted file mode 100644
index 1cd9d95..0000000
--- a/Assignement12/.classpath
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/Assignement12/.project b/Assignement12/.project
deleted file mode 100644
index e0eb974..0000000
--- a/Assignement12/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- Assignement12
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
-
-
diff --git a/Assignement12/.settings/org.eclipse.jdt.core.prefs b/Assignement12/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 910a770..0000000
--- a/Assignement12/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,14 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=14
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=14
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=14
diff --git a/Assignement12/Lab12-Part-A.drawio b/Assignement12/Lab12-Part-A.drawio
deleted file mode 100644
index dc85f14..0000000
--- a/Assignement12/Lab12-Part-A.drawio
+++ /dev/null
@@ -1 +0,0 @@
-7Vnfb9owEP5rkLYHJpJASh8htNsDraoxdc8mcROvTg455lf/+p2xnRACLWPNqDQkhOLP54t933c+K255Qbr6KsgsuYOI8pbbiVYtb9Ry3euuj/8KWGvAd7oaiAWLNOSUwIS9UAN2DDpnEc0rhhKASzargiFkGQ1lBSNCwLJq9gS8+tYZiWkNmISE19GfLJKJRvu9Tol/oyxO7JudjulJiTU2QJ6QCJZbkHfT8gIBIPVTugooV7GzcdHjbg/0FhMTNJPHDPh1z10nX4drcv/IbtvtRzIZt22YF4TPzYqHZrpybWOQL1nKSYat4RNkcmJ6HGwTzuIMn0OcBBUILKiQDMM3MB0SZoiGCePRmKxhrqaaSxI+29YwAcFe0C3hxid2C2mU4PoVi4kaiXAHUUFztHmw63d2oDuyqhiOSS4NEALnZJazabGMlIiYZUOQElJjZOKCy6GrgxF3Ch5R/xRSKsUaTewA30TXaN/tmGRYlkoqbJJtFVkREaPeuPBdEowPhuM/4dup8d1W2UkkGba8gRqOa9sVAIZAbogR8EwD4IBMjzLQimCc70BWFJw+yYOSyGckZFk83tiMuiXy3cRBQYBjn/gmaxIWRTRTdILE2WruFFEzwClv4tQb4g8jF3S+9Fo9nHiAbads40+ZCxlAhmshbEMjRWEsqRLHcZy/kkd1JVjmjyTe2r0/726N9xrLnG3Y0yzbzc45ieIUyeK05PSHonzUdmq8e3XevT0cczKl/AFyJhko/0Lb7nB/Nnp77nH09pti19vD7lCVu0+fdVYvAB0odXmO3txUb2x7LznfgCisAN4SRbepvd6viSK4lPaGSrvnX527tF8drOzBJctPz3L/Yxf2/qWuN0buucv69aWqf7R8P3tRr5/jB5ei3lBR7x5JttNpageon+ttTR9s5bjPFS9TgU+xFr9G5iWgNoaITuexHjYF4JRk1hDntmX7n24Z26miXCcytQo/fTdx3+X04HUb0lf3cnpojNxjS0VTe0fvcnr496eHNyTRP/Ppwakn/M1K0izKa1wjOFD3J9iaclBVfIiQKfOOr5u3TL1//3ZJo9rNyk4hxvfBXIT0tQmbSOARI6YnBH5fpAXlRLJFdXL7Qm3cPcAmF+wpoV89JBRurQe9JjNo+z5mx0/B8iFHes01RxviiyX+hRbqG8TH1oJ/pBQOfZdrQAtur8qhu/t152gx7DhyPP+dxIDN8o5Rm5cXtd7Nbw==
\ No newline at end of file
diff --git a/Assignement12/Lab12-Part-A.png b/Assignement12/Lab12-Part-A.png
deleted file mode 100644
index 66de72f..0000000
Binary files a/Assignement12/Lab12-Part-A.png and /dev/null differ
diff --git a/Assignement12/Lab12-Part-B.drawio b/Assignement12/Lab12-Part-B.drawio
deleted file mode 100644
index c515d4a..0000000
--- a/Assignement12/Lab12-Part-B.drawio
+++ /dev/null
@@ -1 +0,0 @@
-7Vrbbts4EP0aA90HB7rbfvQlSQukW2+drXf7xkiMRIQWDYpO5H79Dk3K1s2XpLKTBQQYhmY0HJE8Z4YzkDr2eJHecrSMvrIA045lBGnHnnQsa+B48C8Va6XwzJ5ShJwESmXuFDPyC2ulobUrEuCkYCgYo4Isi0qfxTH2RUGHOGcvRbNHRotPXaIQVxQzH9Gqdk4CESlt3zV2+s+YhFH2ZNPQdxYoM9aKJEIBe8mp7OuOPeaMCXW1SMeYyr3L9kWNu9lzdzsxjmNxygC/697NBg/231/+QvNb9jQ1Zl7XVV6eEV3pBV+nAsdBoucs1tlGgHIo9xOkB8r8p449ApUGzPSUeEPgkfbEACkSC3lpyhspEf9I9ZWrpX+1kbyepHlhrQX1fBxU0NktV6sStuK+thr86UeWd/PjpzCD6T1Z9v1v825GG8RDrIcGN7E7RN/TcObfTuar+YymPWWn9+4WswUWfA3jXnawm57GkmOKBHkuzg1pqoXbsVt3U0Zg1paho6Kv3WQx4TlFD2pJelAe0pIfyzniSK254gguckvcqTaMeQV7vEuwp0EmuB+OCaZVRNDpvZEKtll0ZPcvS4XeZROJYw5yqaRrXBmmdTCfSGGKOYF1Yt58jhl8PGbZJWaVCXFyknHtK6PnDSxb/ZtFt8Zledav8OwUgiUwK1HDOk0zMzPJyb+dgfbjfwJP3IvxxCllINt6I0/c/hFHzTHj0DGfY8ZXlE6QQBOSLClaV3iSvJAFRTFIo0cWi5m+IxFHlIQxXPsAsEwXo2fMBYGqcKhvCLYErR8RGtyhNVtJLIFB/lMmjSLGyS9wiwoE02nO8goWMzlSJyWOE7CZZtwySypYU8HwDiVCK3xGKVom5GG7jAXsOIlHTAi2KOS8GurKFeI0p6qyLztqSoklKzrqyBnlauO+t5+bBTK8Fnmrgnx3U4CnP5RmKB1o0uUJAOsVG2A4e8JjRpk8GGKmGAGZoKTKSEHxo9hLiWSJfBKHdxubibPTfNcbIVUMxj7STTKKSBDgWMLJBHBVYSeBWso42eyUO4If7OdY1s8uTHwMsrmT4SfNuRizGNaCyAZZDMR4wZIcNZgfDKDjRNDIW95pwFvnAt4+fhhQssFOYZx1cOabAF4AVBTvEL2XgE+6ZgV1u4q6XYMwRQ+YTllCBGHSP1e2JeTfC1zXOjGqz4StU4MtLNZYLQMk8Kc/VFg/M3DSxnWz0Gcwv1tcDyrYjxgPMG9P8+ZPc+etx3mmaxx9s1rJtWn9SKQ0fmafK62b1WKtzesXwt4+MbKbyOuHut8c9m1Gbz6jlxs0qzc4Dfftu4vGga/v0CDg0T0bYU0AHKjYl5xoY3+L/8FI+pC9Wu2M217tfOBesFernfC+Xi3EcisErDY71+WWqJ2SRJMvLeSutOf/RWhyal/nnKuyr75t/kwSwUKOFm0hcP5C4P1bu+pbwvYQOBIr/5vOru7NXJvYLwL9uzd21cReW8S3ifxtidwtfdxhOdWObvvFXKGjayKT1yJe/fRHdnS+qvZUqA85R+s7OOCh1qMSoC9wMwRwLS9U0bAtAeVY9pBgDnuS7BldqBAyD20iOVQhNnGG1PLKcc5Eq7ZAOB+4vWr5XwvuubrEfQXCa7pEFAT3LLMGs0JVUbIVbCY4IJZ5VVLVpYCzIPqUSy+HnMZMkMf1kNJvWbpqK5tzcrZ/ImetV5MWxN3H1+ojpN0X7Pb1fw==
\ No newline at end of file
diff --git a/Assignement12/Lab12-Part-B.png b/Assignement12/Lab12-Part-B.png
deleted file mode 100644
index f07cddb..0000000
Binary files a/Assignement12/Lab12-Part-B.png and /dev/null differ
diff --git a/Assignement12/bin/A.class b/Assignement12/bin/A.class
deleted file mode 100644
index cce7344..0000000
Binary files a/Assignement12/bin/A.class and /dev/null differ
diff --git a/Assignement12/bin/B.class b/Assignement12/bin/B.class
deleted file mode 100644
index 31a0a2d..0000000
Binary files a/Assignement12/bin/B.class and /dev/null differ
diff --git a/Assignement12/bin/BorderDataDisplay.class b/Assignement12/bin/BorderDataDisplay.class
deleted file mode 100644
index 28fee5b..0000000
Binary files a/Assignement12/bin/BorderDataDisplay.class and /dev/null differ
diff --git a/Assignement12/bin/C.class b/Assignement12/bin/C.class
deleted file mode 100644
index fb920ce..0000000
Binary files a/Assignement12/bin/C.class and /dev/null differ
diff --git a/Assignement12/bin/Data.class b/Assignement12/bin/Data.class
deleted file mode 100644
index d8e2b65..0000000
Binary files a/Assignement12/bin/Data.class and /dev/null differ
diff --git a/Assignement12/bin/DataDisplay.class b/Assignement12/bin/DataDisplay.class
deleted file mode 100644
index 8196c7d..0000000
Binary files a/Assignement12/bin/DataDisplay.class and /dev/null differ
diff --git a/Assignement12/bin/HistogramDataDisplay.class b/Assignement12/bin/HistogramDataDisplay.class
deleted file mode 100644
index 0178222..0000000
Binary files a/Assignement12/bin/HistogramDataDisplay.class and /dev/null differ
diff --git a/Assignement12/bin/MaxDataDisplay.class b/Assignement12/bin/MaxDataDisplay.class
deleted file mode 100644
index a30bb41..0000000
Binary files a/Assignement12/bin/MaxDataDisplay.class and /dev/null differ
diff --git a/Assignement12/bin/PartA.class b/Assignement12/bin/PartA.class
deleted file mode 100644
index 41edfb8..0000000
Binary files a/Assignement12/bin/PartA.class and /dev/null differ
diff --git a/Assignement12/bin/PartB.class b/Assignement12/bin/PartB.class
deleted file mode 100644
index f36092e..0000000
Binary files a/Assignement12/bin/PartB.class and /dev/null differ
diff --git a/Assignement12/src/A.java b/Assignement12/src/A.java
deleted file mode 100644
index 562e42e..0000000
--- a/Assignement12/src/A.java
+++ /dev/null
@@ -1,21 +0,0 @@
-
-public class A {
- private int dataA;
- public static boolean debug;
-
- public A(int a) {
- if (A.debug) {
- System.out.println("constructor A is being called!");
- }
- this.dataA = a;
- }
-
- public void f() {
-
- System.out.println("method f() from class A is being called");
- }
-
- public int g() {
- return this.dataA + 1;
- }
-}
diff --git a/Assignement12/src/B.java b/Assignement12/src/B.java
deleted file mode 100644
index 0544b39..0000000
--- a/Assignement12/src/B.java
+++ /dev/null
@@ -1,23 +0,0 @@
-
-public class B extends A {
- private int dataB;
-
- public B(int a, int b) {
- super(a);
- if (A.debug) {
- System.out.println("constructor B is being called!");
- }
- this.dataB = b;
- }
-
- @Override
- public void f() {
-
- System.out.println("method f() from class B is being called");
- }
-
- @Override
- public int g() {
- return 2 * super.g() + dataB;
- }
-}
diff --git a/Assignement12/src/BorderDataDisplay.java b/Assignement12/src/BorderDataDisplay.java
deleted file mode 100644
index 29de8e9..0000000
--- a/Assignement12/src/BorderDataDisplay.java
+++ /dev/null
@@ -1,15 +0,0 @@
-
-public class BorderDataDisplay extends DataDisplay {
-
- public BorderDataDisplay(String name, Data subject) {
- super(name, subject);
- }
-
- @Override
- public void update() {
- System.out.println("*".repeat(25));
- super.update();
- System.out.println("*".repeat(25));
- }
-
-}
diff --git a/Assignement12/src/C.java b/Assignement12/src/C.java
deleted file mode 100644
index 9f86bc2..0000000
--- a/Assignement12/src/C.java
+++ /dev/null
@@ -1,22 +0,0 @@
-public class C extends B {
- private int dataC;
-
- public C(int a, int b, int c) {
- super(a, b);
- if (A.debug) {
- System.out.println("constructor C is being called!");
- }
- this.dataC = c;
- }
-
- @Override
- public void f() {
- super.f();
- System.out.println("method f() from class C is being called");
- }
-
- @Override
- public int g() {
- return super.g() - 10 + dataC * 3;
- }
-}
diff --git a/Assignement12/src/Data.java b/Assignement12/src/Data.java
deleted file mode 100644
index 2c770df..0000000
--- a/Assignement12/src/Data.java
+++ /dev/null
@@ -1,40 +0,0 @@
-import java.util.ArrayList;
-import java.util.Arrays;
-
-public class Data {
-
- private ArrayList observers = new ArrayList();
- private ArrayList content;
-
- public Data() {
- content = new ArrayList();
- }
-
- public int[] getContent() {
- int[] result = new int[content.size()];
- for (int i = 0; i < result.length; i++) {
- result[i] = content.get(i);
- }
- return result;
- }
-
- public void addToContent(int x) {
- content.add(x);
- System.out.println("\nData: " + x + " is added.");
- notifyAllObservers();
- }
-
- public String toString() {
- return Arrays.toString(content.toArray());
- }
-
- public void attach(DataDisplay observer) {
- observers.add(observer);
- }
-
- public void notifyAllObservers() {
- for (DataDisplay observer : observers) {
- observer.update();
- }
- }
-}
diff --git a/Assignement12/src/DataDisplay.java b/Assignement12/src/DataDisplay.java
deleted file mode 100644
index adfbc67..0000000
--- a/Assignement12/src/DataDisplay.java
+++ /dev/null
@@ -1,19 +0,0 @@
-
-public class DataDisplay {
- String name;
- private Data dataToBeDisplayed;
-
- public DataDisplay(String name, Data subject) {
- dataToBeDisplayed = subject;
- this.name = name;
- }
-
- public int[] getContent() {
- return dataToBeDisplayed.getContent();
- }
-
- public void update() {
- System.out.println(getClass() + ": " + name);
- System.out.println("\t" + dataToBeDisplayed);
- }
-}
diff --git a/Assignement12/src/HistogramDataDisplay.java b/Assignement12/src/HistogramDataDisplay.java
deleted file mode 100644
index 563c55f..0000000
--- a/Assignement12/src/HistogramDataDisplay.java
+++ /dev/null
@@ -1,16 +0,0 @@
-public class HistogramDataDisplay extends DataDisplay {
-
- public HistogramDataDisplay(String name, Data subject) {
- super(name, subject);
- }
-
- @Override
- public void update() {
- System.out.println(getClass() + ": " + name);
- for (int i = 0; i < super.getContent().length; i++)
- System.out.format("%s%d\t%s", (i == 0) ? "" : "\n", super.getContent()[i],
- "*".repeat(super.getContent()[i]));
-
- System.out.println();
- }
-}
diff --git a/Assignement12/src/MaxDataDisplay.java b/Assignement12/src/MaxDataDisplay.java
deleted file mode 100644
index 2fffae2..0000000
--- a/Assignement12/src/MaxDataDisplay.java
+++ /dev/null
@@ -1,15 +0,0 @@
-
-public class MaxDataDisplay extends DataDisplay {
- int maxValue=0;
- public MaxDataDisplay(String name, Data subject) {
- super(name, subject);
- }
- @Override
- public void update() {
- System.out.println(getClass() + ": " + name);
- for(int i : super.getContent()) this.maxValue = Math.max(this.maxValue, i);
- System.out.println(this.maxValue);
-
- }
-
-}
diff --git a/Assignement12/src/PartA.java b/Assignement12/src/PartA.java
deleted file mode 100644
index c535284..0000000
--- a/Assignement12/src/PartA.java
+++ /dev/null
@@ -1,63 +0,0 @@
-
-public class PartA {
- public static void main(String[] args) {
- testConstructor();
- A a = new A(2);
- A b = new B(3, 4);
- A c = new C(5, 6, 7);
- testF(a, b, c);
- testG(a, b, c);
- testA();
- testB();
- testC();
- }
- private static void testF(A a, A b, A c) {
- System.out.println("--- Test f() of A, B, C ---");
- a.f();
- System.out.println("------------------------------");
- b.f();
- System.out.println("------------------------------");
- c.f();
- System.out.println("------------------------------");
- }
- private static void testG(A a, A b, A c) {
- System.out.println("--- Test g() of A, B, C ------");
- System.out.println(a.getClass() + ": " + a.g());
- System.out.println("------------------------------");
- System.out.println(b.getClass() + ": " + b.g());
- System.out.println("------------------------------");
- System.out.println(c.getClass() + ": " + c.g());
- System.out.println("------------------------------");
- }
- public static void testConstructor() {
- A.debug = true;
- A a = new A(2);
- System.out.println("------------------------------");
- A b = new B(3, 4);
- System.out.println("------------------------------");
- A c = new C(5, 6, 7);
- System.out.println("------------------------------");
- A.debug = false;
- }
-
- public static void testA() {
- System.out.format("new A(2).g() -> %d, [expected] -> %d\n", new A(2).g(), 3);
- System.out.format("new A(-1).g() -> %d, [expected] -> %d\n", new A(-1).g(), 0);
- System.out.format("new A(-10).g() -> %d, [expected] -> %d\n", new A(-10).g(), -9);
- System.out.format("new A(0).g() -> %d, [expected] -> %d\n", new A(0).g(), 1);
- }
-
- public static void testB() {
- System.out.format("new B(0, 0).g() -> %d, [expected] -> %d\n", new B(0, 0).g(), 2);
- System.out.format("new B(-2, 3).g() -> %d, [expected] -> %d\n", new B(-2, 3).g(), 1);
- System.out.format("new B(2, -3).g() -> %d, [expected] -> %d\n", new B(2, -3).g(), 3);
- System.out.format("new B(4, 5).g() -> %d, [expected] -> %d\n", new B(4, 6).g(), 16);
- }
-
- public static void testC() {
- System.out.format("new C(0, 0, 0).g() -> %d, [expected] -> %d\n", new C(0, 0, 0).g(), -8);
- System.out.format("new C(2, 4, 3).g() -> %d, [expected] -> %d\n", new C(2, 4, 3).g(), 9);
- System.out.format("new C(-1, -3, -5).g() -> %d, [expected] -> %d\n", new C(-1, -3, 5).g(), 2);
- System.out.format("new C(5, 2, 10).g() -> %d, [expected] -> %d\n", new C(5, 2, 10).g(), 34);
- }
-}
diff --git a/Assignement12/src/PartB.java b/Assignement12/src/PartB.java
deleted file mode 100644
index 64421e2..0000000
--- a/Assignement12/src/PartB.java
+++ /dev/null
@@ -1,26 +0,0 @@
-import java.util.Scanner;
-
-public class PartB {
- public static void main(String[] args) {
- Data d = new Data();
- DataDisplay display = new DataDisplay("General Display", d);
- DataDisplay maxDisplay = new MaxDataDisplay("MAX-Display", d);
- DataDisplay histogram = new HistogramDataDisplay("Histogram", d);
- DataDisplay border = new BorderDataDisplay("Display-with-border", d);
- d.attach(display);
- d.attach(maxDisplay);
- d.attach(histogram);
- d.attach(border);
-
- Scanner kbd = new Scanner(System.in);
- while (true) {
- System.out.println("------------------------------");
- System.out.print("Enter an integer >= 0: ");
- int x = kbd.nextInt();
- if (x < 0)
- break;
- d.addToContent(x);
- }
- System.out.println("--- FINISH ---");
- }
-}
diff --git a/Assignment10/Siwat-Java-Assignment10.docx b/Assignment10/Siwat-Java-Assignment10.docx
deleted file mode 100644
index 1ebfaef..0000000
Binary files a/Assignment10/Siwat-Java-Assignment10.docx and /dev/null differ
diff --git a/Assignment10/Siwat-Java-Assignment10.pdf b/Assignment10/Siwat-Java-Assignment10.pdf
deleted file mode 100644
index c3cd273..0000000
Binary files a/Assignment10/Siwat-Java-Assignment10.pdf and /dev/null differ
diff --git a/Assignment10/Siwat-Java-Assignment10v2.pdf b/Assignment10/Siwat-Java-Assignment10v2.pdf
deleted file mode 100644
index 971f29b..0000000
Binary files a/Assignment10/Siwat-Java-Assignment10v2.pdf and /dev/null differ
diff --git a/Assignment10/bin/RecursiveExercise.class b/Assignment10/bin/RecursiveExercise.class
index cbdeec5..9dec825 100644
Binary files a/Assignment10/bin/RecursiveExercise.class and b/Assignment10/bin/RecursiveExercise.class differ
diff --git a/Assignment10/bin/RecursiveExerciseSandwich.class b/Assignment10/bin/RecursiveExerciseSandwich.class
deleted file mode 100644
index 9a9e540..0000000
Binary files a/Assignment10/bin/RecursiveExerciseSandwich.class and /dev/null differ
diff --git a/Assignment10/src/RecursiveExercise.java b/Assignment10/src/RecursiveExercise.java
index 1b5e706..066eea1 100644
--- a/Assignment10/src/RecursiveExercise.java
+++ b/Assignment10/src/RecursiveExercise.java
@@ -13,17 +13,29 @@ public class RecursiveExercise {
int head = MyArrayUtil.head(ht);
return MyArrayUtil.addAsFirst(head, l);
}
-
public static int[] reverse(int[] ht) throws Exception {
// fill your code here
- if (ht == null)
- return null;
+ if(ht == null) return null;
if (ht.length == 1)
return ht.clone();
- return append(reverse(MyArrayUtil.tail(ht)),new int[] {MyArrayUtil.head(ht)});
+ int temp = ht[0];
+ ht[0] = ht[ht.length - 1];
+ ht[ht.length - 1] = temp;
+ return recursiveInnerSandwich(reverse(MyArrayUtil.tail(removeLast(ht, new int[ht.length-1], 0))),ht.clone());
+ }
+ //This method make an array sandwich excluding the bread (index 0 and index last)
+ public static int[] recursiveInnerSandwich(int[] src,int[] dest) throws Exception{
+ if (src==null)return dest;
+ dest[dest.length-src.length-1] = src[0];
+ recursiveInnerSandwich(MyArrayUtil.tail(src),dest);
+ return dest;
+ }
+ //Remove the last element
+ public static int[] removeLast(int[] ia1,int[] ia2,int i) {
+ ia2[i]=ia1[i];
+ if (i==ia2.length-1)return ia2;
+ return removeLast(ia1,ia2,i+1);
}
-
-
public static boolean isIn(int x, int[] a) throws Exception {
// fill your code here
if (a[0] == x)
@@ -46,15 +58,12 @@ public class RecursiveExercise {
public static int[] shift(int[] ht, int n) throws Exception {
// fill your code here
- if (ht == null)
- return null;
- if (n == 0)
- return ht;
+ if(ht==null)return null;
+ if(n==0)return ht;
int temp = ht[0];
ht = reverse(MyArrayUtil.addAsFirst(temp, reverse(MyArrayUtil.tail(ht))));
- return shift(ht, n - 1);
+ return shift(ht,n-1);
}
-
public static void main(String[] args) throws Exception {
// test append, when appending empty array with {1,2,3}
int[] a = null;
diff --git a/Assignment10/src/RecursiveExerciseSandwich.java b/Assignment10/src/RecursiveExerciseSandwich.java
deleted file mode 100644
index 0ae8a6f..0000000
--- a/Assignment10/src/RecursiveExerciseSandwich.java
+++ /dev/null
@@ -1,162 +0,0 @@
-import java.util.Arrays;
-
-public class RecursiveExerciseSandwich {
-
- // return an array that has all data of ht and n,
- // just like concatenating ht and n.
- public static int[] append(int[] ht, int[] n) throws Exception {
- if (ht == null)
- return n;
- if (n == null)
- return ht;
- int[] l = append(MyArrayUtil.tail(ht), n);
- int head = MyArrayUtil.head(ht);
- return MyArrayUtil.addAsFirst(head, l);
- }
- public static int[] reverse(int[] ht) throws Exception {
- // fill your code here
- if(ht == null) return null;
- if (ht.length == 1)
- return ht.clone();
- int temp = ht[0];
- ht[0] = ht[ht.length - 1];
- ht[ht.length - 1] = temp;
- return recursiveInnerSandwich(reverse(MyArrayUtil.tail(removeLast(ht, new int[ht.length-1], 0))),ht.clone());
- }
- //This method make an array sandwich excluding the bread (index 0 and index last)
- public static int[] recursiveInnerSandwich(int[] src,int[] dest) throws Exception{
- if (src==null)return dest;
- dest[dest.length-src.length-1] = src[0];
- recursiveInnerSandwich(MyArrayUtil.tail(src),dest);
- return dest;
- }
- //Remove the last element
- public static int[] removeLast(int[] ia1,int[] ia2,int i) {
- ia2[i]=ia1[i];
- if (i==ia2.length-1)return ia2;
- return removeLast(ia1,ia2,i+1);
- }
- public static boolean isIn(int x, int[] a) throws Exception {
- // fill your code here
- if (a[0] == x)
- return true;
- if (a.length == 1)
- return false;
- return isIn(x, MyArrayUtil.tail(a.clone()));
- }
-
- public static boolean subArray(int[] a1, int[] a2) throws Exception {
- // fill your code here
- if (a1 == null)
- return true;
- if (isIn(a1[0], a2))
- return subArray(MyArrayUtil.tail(a1.clone()), a2);
- if (a1.length == 1)
- return true;
- return false;
- }
-
- public static int[] shift(int[] ht, int n) throws Exception {
- // fill your code here
- if(ht==null)return null;
- if(n==0)return ht;
- int temp = ht[0];
- ht = reverse(MyArrayUtil.addAsFirst(temp, reverse(MyArrayUtil.tail(ht))));
- return shift(ht,n-1);
- }
- public static void main(String[] args) throws Exception {
- // test append, when appending empty array with {1,2,3}
- int[] a = null;
- int[] b = { 1, 2, 3 };
- int[] ans1 = append(a, b);
- System.out.println("Append - Expected: 1, 2, 3.");
- System.out.print("Get: ");
- MyArrayUtil.print(ans1);
- System.out.println("");
-
- // test append, when appending 2 non-empty arrays.
- int[] c = { 1, 2, 3 };
- int[] d = { 4, 5, 6 };
- ans1 = append(c, d);
- System.out.println("Append - Expected: 1, 2, 3, 4, 5, 6.");
- System.out.print("Get: ");
- MyArrayUtil.print(ans1);
- System.out.println("");
-
- // test reverse
- int[] e = { 1, 2, 3, 4, 5 };
- ans1 = reverse(e);
- System.out.println("Reverse - Expected: 5, 4, 3, 2, 1.");
- System.out.print("Get: ");
- MyArrayUtil.print(ans1);
- System.out.println("");
-
- // test isIn
- boolean b1 = isIn(3, e);
- System.out.println("isIn - Expected: true.");
- System.out.println("Get: " + b1 + ".");
-
- boolean b2 = isIn(7, e);
- System.out.println("isIn - Expected: false.");
- System.out.println("Get: " + b2 + ".");
-
- // test subArray
- int[] f = { 1, 3, 5 };
- int[] g = { 1, 2, 3, 4, 5 };
- int[] h = { 1, 2, 3, 4, 5 };
- int[] i = null;
- int[] j = { 1, 4, 5 };
-
- b1 = subArray(f, g);
- System.out.println("subArray - Expected: true.");
- System.out.println("Get: " + b1 + ".");
-
- b1 = subArray(g, h);
- System.out.println("subArray - Expected: true.");
- System.out.println("Get: " + b1 + ".");
-
- b1 = subArray(i, h);
- System.out.println("subArray - Expected: true.");
- System.out.println("Get: " + b1 + ".");
-
- b1 = subArray(f, j);
- System.out.println("subArray - Expected: false.");
- System.out.println("Get: " + b1 + ".");
-
- b1 = subArray(h, j);
- System.out.println("subArray - Expected: false.");
- System.out.println("Get: " + b1 + ".");
-
- // test shift
- int[] k = shift(g, 3);
- System.out.println("shift - Expected: 4, 5, 1, 2, 3.");
- System.out.print("Get: ");
- MyArrayUtil.print(k);
- System.out.println("");
-
- k = shift(g, 2);
- System.out.println("shift - Expected: 3, 4, 5, 1, 2.");
- System.out.print("Get: ");
- MyArrayUtil.print(k);
- System.out.println("");
-
- k = shift(g, 8);
- System.out.println("shift - Expected: 4, 5, 1, 2, 3.");
- System.out.print("Get: ");
- MyArrayUtil.print(k);
- System.out.println("");
-
- k = shift(g, 0);
- System.out.println("shift - Expected: 1, 2, 3, 4, 5.");
- System.out.print("Get: ");
- MyArrayUtil.print(k);
- System.out.println("");
-
- k = shift(null, 5);
- System.out.println("shift - Expected: Array empty");
- System.out.print("Get: ");
- MyArrayUtil.print(k);
- System.out.println("");
- }
-
-}
diff --git a/Assignment11/.classpath b/Assignment11/.classpath
deleted file mode 100644
index 70188ff..0000000
--- a/Assignment11/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Assignment11/.project b/Assignment11/.project
deleted file mode 100644
index bf69837..0000000
--- a/Assignment11/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- Assignment11
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
-
-
diff --git a/Assignment11/.settings/org.eclipse.jdt.core.prefs b/Assignment11/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 910a770..0000000
--- a/Assignment11/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,14 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=14
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=14
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=14
diff --git a/Assignment11/bin/Witch.class b/Assignment11/bin/Witch.class
deleted file mode 100644
index fec7465..0000000
Binary files a/Assignment11/bin/Witch.class and /dev/null differ
diff --git a/Assignment11/bin/WitchGame.class b/Assignment11/bin/WitchGame.class
deleted file mode 100644
index 439a72c..0000000
Binary files a/Assignment11/bin/WitchGame.class and /dev/null differ
diff --git a/Assignment11/src/Witch.java b/Assignment11/src/Witch.java
deleted file mode 100644
index 2fd9e50..0000000
--- a/Assignment11/src/Witch.java
+++ /dev/null
@@ -1,189 +0,0 @@
-public class Witch {
-
- // Static Fields
- private static int totalWitches = 0;
-
- // Non-Static Fields
- private String name;
- private String school;
- private int magicPower;
-
- // Static Constants
- static final int MAX_LEVEL = 100;
- static final int MIN_LEVEL = 0;
-
- // Constructors
- /**
- * This is the default constructor
- *
- * @category constructor
- * @param None This constructor takes no parameter
- */
- public Witch() {
- this.name = "no one";
- this.school = "unknown school";
- this.magicPower = 10;
- Witch.totalWitches++;
- }
-
- /**
- * Initialize this witch object with data from parameter
- *
- * @category constructor
- * @param name The name of the witch
- * @param school The school that the witch belong to
- * @param magicPower The magicPower of the witch
- */
- public Witch(String name, String school, int magicPower) {
- this.name = name;
- this.school = school;
- this.magicPower = magicPower;
- Witch.totalWitches++;
- }
-
- /**
- * Initialize this witch object with data from w
- *
- * @category constructor
- * @param w Witch to clone from
- */
- public Witch(Witch w) {
- this.magicPower = w.getMagicPower();
- this.name = w.getName();
- this.school = w.getSchool();
- Witch.totalWitches++;
- }
-
- // Getters
- /**
- * Get the number of witch created
- *
- * @category getter
- * @return totalWitches The total number of witch created
- */
- public static int getTotalWitches() {
- return Witch.totalWitches;
- }
-
- /**
- * Get the name of the witch
- *
- * @category getter
- * @return name name of the witch
- */
- public String getName() {
- return this.name;
- }
-
- /**
- * Get the magic power of the witch
- *
- * @category getter
- * @return magicPower The magic power of the witch
- */
- public int getMagicPower() {
- return this.magicPower;
- }
-
- /**
- * Get the school of the witch
- *
- * @category getter
- * @return school The school of the witch
- */
- public String getSchool() {
- return this.school;
- }
-
- // Setters
- /**
- * Set the totalWitches field
- *
- * @category setter
- * @param totalWitches The value of totalWitches to set
- */
- public static void setTotalWitches(int totalWitches) {
- Witch.totalWitches = totalWitches;
- }
-
- /**
- * Set the name of the witch
- *
- * @category setter
- * @param name The name of the witch to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Set the magic power of the witch
- *
- * @category setter
- * @param magicPower the magic power to set (0<=magicPower<=100), numbers out of
- * range will be rounded up/down to MAX_LEVEL and MIN_LEVEL
- */
- public void setMagicPower(int magicPower) {
- if (magicPower < MIN_LEVEL)
- magicPower = MIN_LEVEL;
- if (magicPower > MAX_LEVEL)
- magicPower = MAX_LEVEL;
- this.magicPower = magicPower;
- }
-
- /**
- * Set the school of the witch
- *
- * @category setter
- * @param school The school that the witch belong to.
- */
- public void setSchool(String school) {
- this.school = school;
- }
-
- // Utilities
- /**
- * Return the object as a formatted string
- *
- * @category utility
- * @Override java.lang.Object.toString()
- * @return WitchString The formatted string containing all field of Object Witch
- */
- @Override
- public String toString() {
- return String.format("Witchname: %s, School: %s, Magic Power: %s", this.name, this.school, this.magicPower);
- }
-
- /**
- * Compare the power level of this witch to witch w
- *
- * @category utility
- * @param w The second witch object
- * @return intPowerCompare 1 if this>w, 2 if this==w, 3 if this w.magicPower)
- return 1;
- else if (this.magicPower == w.magicPower)
- return 0;
- else if (this.magicPower < w.magicPower)
- return -1;
- return 9999; // This statement should not be called
- }
-
- /**
- * Increase the witch's magicPower
- *
- * @category utility
- * @param increase a positive integer to increase the level of the witch by
- * (this.magicPower+increase must be less than MAX_LEVEL)
- */
- public void levelUp(int increase) {
- if (increase < 0)
- return;
- if (this.magicPower + increase > MAX_LEVEL)
- this.magicPower = MAX_LEVEL;
- else
- this.magicPower += increase;
- }
-}
diff --git a/Assignment11/src/WitchGame.java b/Assignment11/src/WitchGame.java
deleted file mode 100644
index 714c144..0000000
--- a/Assignment11/src/WitchGame.java
+++ /dev/null
@@ -1,49 +0,0 @@
-
-public class WitchGame {
- static final String LINE_BREAK = "====================";
-
- public static void main(String[] args) {
- //Object Creation and Initialization
- Witch witch1 = new Witch();
- Witch witch2 = new Witch("Akko", "Luna Nova", 25);
-
- //toString() method test
- System.out.format("%s%n%s%n%s%n", LINE_BREAK, "Printing 2 witches", LINE_BREAK);
- System.out.format("%s%n%s%n", witch1.toString(), witch2.toString());
-
- //Getters and Setters test
- witch1.setName("Hermione Granger");
- witch1.setSchool("Hogwarts");
- witch1.setMagicPower(85);
- //compareTo(Witch w) test
- System.out.format("%s%n%s%n%s%n", LINE_BREAK, "Printing the comparison", LINE_BREAK);
- System.out.format("%s%n", parseCompareTo(witch1,witch2));
-
- //Copy Constructor test
- Witch witch3 = new Witch(witch1);
- witch3.levelUp(80);
- System.out.format("%s%n", parseCompareTo(witch2,witch3));
-
- //Print all witch
- System.out.format("%s%n%s%n%s%n", LINE_BREAK, "Now, printing all witches.", LINE_BREAK);
- System.out.format("%s%n%s%n%s%n",witch1.toString(),witch2.toString(),witch3.toString());
-
- //Print Total witches
- System.out.format("%s%n%s%n%s%n", LINE_BREAK, "Now, printing total number of witches", LINE_BREAK);
- System.out.println(Witch.getTotalWitches());
-
- }
-
- static String parseCompareTo(Witch witch1,Witch witch2) {
- return switch (witch1.compareTo(witch2)) {
- case 1:
- yield witch1.toString()+" has higher magic power.";
- case 0:
- yield "2 witch have equal magic power.";
- case -1:
- yield witch2.toString()+" has higher magic power.";
- default:
- yield "";
- };
- }
-}
diff --git a/screwdriver-3.5.6/target/classes/META-INF/MANIFEST.MF b/screwdriver-3.5.6/target/classes/META-INF/MANIFEST.MF
index 3ed3806..a397208 100644
--- a/screwdriver-3.5.6/target/classes/META-INF/MANIFEST.MF
+++ b/screwdriver-3.5.6/target/classes/META-INF/MANIFEST.MF
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Built-By: siwat
-Build-Jdk: 15
+Build-Jdk: 14.0.2
Class-Path: log4j-1.2.17.jar jsp-api-2.2.jar
Main-Class: it.ramecera.screwdriver.Hammer
Created-By: Maven Integration for Eclipse
diff --git a/screwdriver-3.5.6/target/classes/META-INF/maven/it.ramecera.ict/screwdriver/pom.properties b/screwdriver-3.5.6/target/classes/META-INF/maven/it.ramecera.ict/screwdriver/pom.properties
index 8f70236..c53c489 100644
--- a/screwdriver-3.5.6/target/classes/META-INF/maven/it.ramecera.ict/screwdriver/pom.properties
+++ b/screwdriver-3.5.6/target/classes/META-INF/maven/it.ramecera.ict/screwdriver/pom.properties
@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
-#Wed Nov 18 13:58:23 ICT 2020
+#Thu Oct 29 16:39:34 ICT 2020
m2e.projectLocation=C\:\\Users\\siwat\\GitHub\\ise-comprog-after-midterm\\screwdriver-3.5.6
m2e.projectName=screwdriver-3.5.6
groupId=it.ramecera.ict
diff --git a/waxds-copper/target/classes/META-INF/maven/it.ramecera.ict/waxds-copper/pom.properties b/waxds-copper/target/classes/META-INF/maven/it.ramecera.ict/waxds-copper/pom.properties
index eef550f..c73ce92 100644
--- a/waxds-copper/target/classes/META-INF/maven/it.ramecera.ict/waxds-copper/pom.properties
+++ b/waxds-copper/target/classes/META-INF/maven/it.ramecera.ict/waxds-copper/pom.properties
@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
-#Wed Nov 18 13:58:25 ICT 2020
+#Tue Nov 03 01:02:01 ICT 2020
m2e.projectLocation=C\:\\Users\\siwat\\GitHub\\ise-comprog-after-midterm\\waxds-copper
m2e.projectName=waxds-copper
groupId=it.ramecera.ict