From cf469b454852b93db632add3538fc809e4525156 Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 8 Apr 2024 10:52:01 +0200 Subject: [PATCH 01/22] 1. dodanie pliku gitignore --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .gitignore diff --git a/ .gitignore b/ .gitignore new file mode 100644 index 00000000..3e36bc95 --- /dev/null +++ b/ .gitignore @@ -0,0 +1,9 @@ +# Ignorowanie folderów i plików generowanych przez narzędzia i IDE +/bin/ +/target/ +/.idea/ +*.iml + +# Ignorowanie plików wygenerowanych przez systemy operacyjne +Thumbs.db +ehthumbs.db From 4e59548ca1786593bdd09d8ed7a8a2b9b68ef876 Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 8 Apr 2024 10:56:18 +0200 Subject: [PATCH 02/22] usuniecie .gitignore --- .gitignore | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 .gitignore diff --git a/ .gitignore b/ .gitignore deleted file mode 100644 index 3e36bc95..00000000 --- a/ .gitignore +++ /dev/null @@ -1,9 +0,0 @@ -# Ignorowanie folderów i plików generowanych przez narzędzia i IDE -/bin/ -/target/ -/.idea/ -*.iml - -# Ignorowanie plików wygenerowanych przez systemy operacyjne -Thumbs.db -ehthumbs.db From 70f53f52f9667f174851cce5b753ee047000bcbb Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 8 Apr 2024 10:58:03 +0200 Subject: [PATCH 03/22] 1. Dodanie pliku .gitignore --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..cd250993 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Ignorowanie folderów i plików generowanych przez narzędzia i IDE +/bin/ +/target/ +/.idea/ +*.iml + +# Ignorowanie plików wygenerowanych przez systemy operacyjne +Thumbs.db +ehthumbs.db \ No newline at end of file From 61a49b697f0e0db66c447680836dfab41ee3bdca Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 8 Apr 2024 11:12:42 +0200 Subject: [PATCH 04/22] 2. Formatowanie kodu w klasie HanoiRhymer --- src/main/java/edu/kis/vh/nursery/HanoiRhymer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java b/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java index 755b2d58..ec0691fc 100644 --- a/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java @@ -2,16 +2,16 @@ public class HanoiRhymer extends defaultCountingOutRhymer { -int totalRejected = 0; + int totalRejected = 0; public int reportRejected() { return totalRejected; } public void countIn(int in) { - if (!callCheck() && in > peekaboo()) + if (!callCheck() && in > peekaboo()) totalRejected++; - else - super.countIn(in); + else + super.countIn(in); } } From 7289a82f3b750e2c049631cd83c6faf9ab515c3b Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 8 Apr 2024 11:48:11 +0200 Subject: [PATCH 05/22] =?UTF-8?q?3.=20Formatowanie=20plik=C3=B3w:=20Uycie?= =?UTF-8?q?=20ctrl+alt+l=20na=20folderze=20/src/main/java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/edu/kis/vh/nursery/FIFORhymer.java | 16 ++++---- .../vh/nursery/defaultCountingOutRhymer.java | 38 +++++++++---------- .../vh/nursery/factory/Rhymersfactory.java | 22 +++++------ .../java/edu/kis/vh/nursery/list/Node.java | 2 +- .../java/edu/kis/vh/nursery/RhymersDemo.java | 16 ++++---- 5 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/main/java/edu/kis/vh/nursery/FIFORhymer.java b/src/main/java/edu/kis/vh/nursery/FIFORhymer.java index 28591ada..94272e46 100644 --- a/src/main/java/edu/kis/vh/nursery/FIFORhymer.java +++ b/src/main/java/edu/kis/vh/nursery/FIFORhymer.java @@ -3,19 +3,19 @@ public class FIFORhymer extends defaultCountingOutRhymer { public defaultCountingOutRhymer temp = new defaultCountingOutRhymer(); - + @Override public int countOut() { while (!callCheck()) - - temp.countIn(super.countOut()); - + + temp.countIn(super.countOut()); + int ret = temp.countOut(); - + while (!temp.callCheck()) - - countIn(temp.countOut()); - + + countIn(temp.countOut()); + return ret; } } diff --git a/src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java b/src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java index 199abf6d..89033a01 100644 --- a/src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java @@ -11,24 +11,24 @@ public void countIn(int in) { NUMBERS[++total] = in; } - public boolean callCheck() { - return total == -1; - } - - public boolean isFull() { - return total == 11; - } - - protected int peekaboo() { - if (callCheck()) - return -1; - return NUMBERS[total]; - } - - public int countOut() { - if (callCheck()) - return -1; - return NUMBERS[total--]; - } + public boolean callCheck() { + return total == -1; + } + + public boolean isFull() { + return total == 11; + } + + protected int peekaboo() { + if (callCheck()) + return -1; + return NUMBERS[total]; + } + + public int countOut() { + if (callCheck()) + return -1; + return NUMBERS[total--]; + } } diff --git a/src/main/java/edu/kis/vh/nursery/factory/Rhymersfactory.java b/src/main/java/edu/kis/vh/nursery/factory/Rhymersfactory.java index 033755d0..b480c321 100644 --- a/src/main/java/edu/kis/vh/nursery/factory/Rhymersfactory.java +++ b/src/main/java/edu/kis/vh/nursery/factory/Rhymersfactory.java @@ -2,14 +2,14 @@ import edu.kis.vh.nursery.defaultCountingOutRhymer; - public interface Rhymersfactory { - - public defaultCountingOutRhymer GetStandardRhymer(); - - public defaultCountingOutRhymer GetFalseRhymer(); - - public defaultCountingOutRhymer GetFIFORhymer(); - - public defaultCountingOutRhymer GetHanoiRhymer(); - - } +public interface Rhymersfactory { + + public defaultCountingOutRhymer GetStandardRhymer(); + + public defaultCountingOutRhymer GetFalseRhymer(); + + public defaultCountingOutRhymer GetFIFORhymer(); + + public defaultCountingOutRhymer GetHanoiRhymer(); + +} diff --git a/src/main/java/edu/kis/vh/nursery/list/Node.java b/src/main/java/edu/kis/vh/nursery/list/Node.java index 0a2cd75e..1704f3ce 100644 --- a/src/main/java/edu/kis/vh/nursery/list/Node.java +++ b/src/main/java/edu/kis/vh/nursery/list/Node.java @@ -8,5 +8,5 @@ public class Node { public Node(int i) { value = i; } - + } diff --git a/src/test/java/edu/kis/vh/nursery/RhymersDemo.java b/src/test/java/edu/kis/vh/nursery/RhymersDemo.java index 05aba9fa..8d299577 100644 --- a/src/test/java/edu/kis/vh/nursery/RhymersDemo.java +++ b/src/test/java/edu/kis/vh/nursery/RhymersDemo.java @@ -9,27 +9,27 @@ class RhymersDemo { public static void main(String[] args) { Rhymersfactory factory = new DefaultRhymersFactory(); - - defaultCountingOutRhymer[] rhymers = { factory.GetStandardRhymer(), factory.GetFalseRhymer(), + + defaultCountingOutRhymer[] rhymers = {factory.GetStandardRhymer(), factory.GetFalseRhymer(), factory.GetFIFORhymer(), factory.GetHanoiRhymer()}; - + for (int i = 1; i < 15; i++) for (int j = 0; j < 3; j++) rhymers[j].countIn(i); - + java.util.Random rn = new java.util.Random(); for (int i = 1; i < 15; i++) rhymers[3].countIn(rn.nextInt(20)); - + for (int i = 0; i < rhymers.length; i++) { while (!rhymers[i].callCheck()) System.out.print(rhymers[i].countOut() + " "); System.out.println(); } - + System.out.println("total rejected is " + ((HanoiRhymer) rhymers[3]).reportRejected()); - + } - + } \ No newline at end of file From 93b6cabb5b30ab8b4a2b74c2f9c5d05ae49ad9fd Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 8 Apr 2024 12:25:37 +0200 Subject: [PATCH 06/22] 4. Zmiana nazwy klasy DefaultCountingOutRhymer by bya z duej litery --- ...efaultCountingOutRhymer.java => DefaultCountingOutRhymer.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/java/edu/kis/vh/nursery/{defaultCountingOutRhymer.java => DefaultCountingOutRhymer.java} (100%) diff --git a/src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java similarity index 100% rename from src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java rename to src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java From 026df9580f2d31acf4ad2b594476ce22128edf26 Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 8 Apr 2024 12:41:37 +0200 Subject: [PATCH 07/22] 4. Zmiana nazw metod by byly z malej litery --- .../vh/nursery/DefaultCountingOutRhymer.java | 2 +- .../java/edu/kis/vh/nursery/FIFORhymer.java | 4 ++-- .../java/edu/kis/vh/nursery/HanoiRhymer.java | 2 +- .../factory/DefaultRhymersFactory.java | 15 +++++++------- .../vh/nursery/factory/Rhymersfactory.java | 10 +++++----- .../java/edu/kis/vh/nursery/RhymersDemo.java | 20 +++++++++---------- .../edu/kis/vh/nursery/RhymersJUnitTest.java | 10 +++++----- 7 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java index 89033a01..b46a9dc8 100644 --- a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java @@ -1,6 +1,6 @@ package edu.kis.vh.nursery; -public class defaultCountingOutRhymer { +public class DefaultCountingOutRhymer { private int[] NUMBERS = new int[12]; diff --git a/src/main/java/edu/kis/vh/nursery/FIFORhymer.java b/src/main/java/edu/kis/vh/nursery/FIFORhymer.java index 94272e46..b4688b4e 100644 --- a/src/main/java/edu/kis/vh/nursery/FIFORhymer.java +++ b/src/main/java/edu/kis/vh/nursery/FIFORhymer.java @@ -1,8 +1,8 @@ package edu.kis.vh.nursery; -public class FIFORhymer extends defaultCountingOutRhymer { +public class FIFORhymer extends DefaultCountingOutRhymer { - public defaultCountingOutRhymer temp = new defaultCountingOutRhymer(); + public DefaultCountingOutRhymer temp = new DefaultCountingOutRhymer(); @Override public int countOut() { diff --git a/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java b/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java index ec0691fc..89ffa912 100644 --- a/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java @@ -1,6 +1,6 @@ package edu.kis.vh.nursery; -public class HanoiRhymer extends defaultCountingOutRhymer { +public class HanoiRhymer extends DefaultCountingOutRhymer { int totalRejected = 0; diff --git a/src/main/java/edu/kis/vh/nursery/factory/DefaultRhymersFactory.java b/src/main/java/edu/kis/vh/nursery/factory/DefaultRhymersFactory.java index 60ba2a16..1387fa70 100644 --- a/src/main/java/edu/kis/vh/nursery/factory/DefaultRhymersFactory.java +++ b/src/main/java/edu/kis/vh/nursery/factory/DefaultRhymersFactory.java @@ -1,29 +1,28 @@ package edu.kis.vh.nursery.factory; -import edu.kis.vh.nursery.defaultCountingOutRhymer; +import edu.kis.vh.nursery.DefaultCountingOutRhymer; import edu.kis.vh.nursery.FIFORhymer; import edu.kis.vh.nursery.HanoiRhymer; -import edu.kis.vh.nursery.factory.Rhymersfactory; public class DefaultRhymersFactory implements Rhymersfactory { @Override - public defaultCountingOutRhymer GetStandardRhymer() { - return new defaultCountingOutRhymer(); + public DefaultCountingOutRhymer getStandardRhymer() { + return new DefaultCountingOutRhymer(); } @Override - public defaultCountingOutRhymer GetFalseRhymer() { - return new defaultCountingOutRhymer(); + public DefaultCountingOutRhymer getFalseRhymer() { + return new DefaultCountingOutRhymer(); } @Override - public defaultCountingOutRhymer GetFIFORhymer() { + public DefaultCountingOutRhymer getFIFORhymer() { return new FIFORhymer(); } @Override - public defaultCountingOutRhymer GetHanoiRhymer() { + public DefaultCountingOutRhymer getHanoiRhymer() { return new HanoiRhymer(); } diff --git a/src/main/java/edu/kis/vh/nursery/factory/Rhymersfactory.java b/src/main/java/edu/kis/vh/nursery/factory/Rhymersfactory.java index b480c321..da726cf0 100644 --- a/src/main/java/edu/kis/vh/nursery/factory/Rhymersfactory.java +++ b/src/main/java/edu/kis/vh/nursery/factory/Rhymersfactory.java @@ -1,15 +1,15 @@ package edu.kis.vh.nursery.factory; -import edu.kis.vh.nursery.defaultCountingOutRhymer; +import edu.kis.vh.nursery.DefaultCountingOutRhymer; public interface Rhymersfactory { - public defaultCountingOutRhymer GetStandardRhymer(); + public DefaultCountingOutRhymer getStandardRhymer(); - public defaultCountingOutRhymer GetFalseRhymer(); + public DefaultCountingOutRhymer getFalseRhymer(); - public defaultCountingOutRhymer GetFIFORhymer(); + public DefaultCountingOutRhymer getFIFORhymer(); - public defaultCountingOutRhymer GetHanoiRhymer(); + public DefaultCountingOutRhymer getHanoiRhymer(); } diff --git a/src/test/java/edu/kis/vh/nursery/RhymersDemo.java b/src/test/java/edu/kis/vh/nursery/RhymersDemo.java index 8d299577..b854e2ee 100644 --- a/src/test/java/edu/kis/vh/nursery/RhymersDemo.java +++ b/src/test/java/edu/kis/vh/nursery/RhymersDemo.java @@ -1,7 +1,5 @@ package edu.kis.vh.nursery; -import edu.kis.vh.nursery.defaultCountingOutRhymer; -import edu.kis.vh.nursery.HanoiRhymer; import edu.kis.vh.nursery.factory.DefaultRhymersFactory; import edu.kis.vh.nursery.factory.Rhymersfactory; @@ -9,27 +7,27 @@ class RhymersDemo { public static void main(String[] args) { Rhymersfactory factory = new DefaultRhymersFactory(); - - defaultCountingOutRhymer[] rhymers = {factory.GetStandardRhymer(), factory.GetFalseRhymer(), - factory.GetFIFORhymer(), factory.GetHanoiRhymer()}; - + + DefaultCountingOutRhymer[] rhymers = { factory.getStandardRhymer(), factory.getFalseRhymer(), + factory.getFIFORhymer(), factory.getHanoiRhymer()}; + for (int i = 1; i < 15; i++) for (int j = 0; j < 3; j++) rhymers[j].countIn(i); - + java.util.Random rn = new java.util.Random(); for (int i = 1; i < 15; i++) rhymers[3].countIn(rn.nextInt(20)); - + for (int i = 0; i < rhymers.length; i++) { while (!rhymers[i].callCheck()) System.out.print(rhymers[i].countOut() + " "); System.out.println(); } - + System.out.println("total rejected is " + ((HanoiRhymer) rhymers[3]).reportRejected()); - + } - + } \ No newline at end of file diff --git a/src/test/java/edu/kis/vh/nursery/RhymersJUnitTest.java b/src/test/java/edu/kis/vh/nursery/RhymersJUnitTest.java index 144906eb..f0f88d99 100644 --- a/src/test/java/edu/kis/vh/nursery/RhymersJUnitTest.java +++ b/src/test/java/edu/kis/vh/nursery/RhymersJUnitTest.java @@ -7,7 +7,7 @@ public class RhymersJUnitTest { @Test public void testCountIn() { - defaultCountingOutRhymer rhymer = new defaultCountingOutRhymer(); + DefaultCountingOutRhymer rhymer = new DefaultCountingOutRhymer(); int testValue = 4; rhymer.countIn(testValue); @@ -17,7 +17,7 @@ public void testCountIn() { @Test public void testCallCheck() { - defaultCountingOutRhymer rhymer = new defaultCountingOutRhymer(); + DefaultCountingOutRhymer rhymer = new DefaultCountingOutRhymer(); boolean result = rhymer.callCheck(); Assert.assertEquals(true, result); @@ -29,7 +29,7 @@ public void testCallCheck() { @Test public void testIsFull() { - defaultCountingOutRhymer rhymer = new defaultCountingOutRhymer(); + DefaultCountingOutRhymer rhymer = new DefaultCountingOutRhymer(); final int STACK_CAPACITY = 12; for (int i = 0; i < STACK_CAPACITY; i++) { boolean result = rhymer.isFull(); @@ -43,7 +43,7 @@ public void testIsFull() { @Test public void testPeekaboo() { - defaultCountingOutRhymer rhymer = new defaultCountingOutRhymer(); + DefaultCountingOutRhymer rhymer = new DefaultCountingOutRhymer(); final int EMPTY_STACK_VALUE = -1; int result = rhymer.peekaboo(); @@ -60,7 +60,7 @@ public void testPeekaboo() { @Test public void testCountOut() { - defaultCountingOutRhymer rhymer = new defaultCountingOutRhymer(); + DefaultCountingOutRhymer rhymer = new DefaultCountingOutRhymer(); final int EMPTY_STACK_VALUE = -1; int result = rhymer.countOut(); From ab50caacfa07074b67723d203dedd5f330903d2e Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 8 Apr 2024 12:52:02 +0200 Subject: [PATCH 08/22] 5. Poprawienie nazw pol klas na poprawne --- .../java/edu/kis/vh/nursery/defaultCountingOutRhymer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java b/src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java index 89033a01..3659f378 100644 --- a/src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java @@ -2,13 +2,13 @@ public class defaultCountingOutRhymer { - private int[] NUMBERS = new int[12]; + private int[] numbers = new int[12]; public int total = -1; public void countIn(int in) { if (!isFull()) - NUMBERS[++total] = in; + numbers[++total] = in; } public boolean callCheck() { @@ -22,13 +22,13 @@ public boolean isFull() { protected int peekaboo() { if (callCheck()) return -1; - return NUMBERS[total]; + return numbers[total]; } public int countOut() { if (callCheck()) return -1; - return NUMBERS[total--]; + return numbers[total--]; } } From ac99eb7dfded742127940d349eba30e82bcb6f40 Mon Sep 17 00:00:00 2001 From: DisturbedCherry Date: Mon, 6 May 2024 11:07:31 +0200 Subject: [PATCH 09/22] =?UTF-8?q?6-7)=20zast=C4=85piono=20literaly=20staly?= =?UTF-8?q?mi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edu/kis/vh/nursery/DefaultCountingOutRhymer.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java index 0c7e4e71..6799a7f2 100644 --- a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java @@ -2,9 +2,11 @@ public class DefaultCountingOutRhymer { - private int[] numbers = new int[12]; + public static final int numbersArraySize = 12; + public static int totalSize = -1; + private int[] numbers = new int[numbersArraySize]; - public int total = -1; + public int total = totalSize; public void countIn(int in) { if (!isFull()) @@ -12,11 +14,11 @@ public void countIn(int in) { } public boolean callCheck() { - return total == -1; + return total == totalSize; } public boolean isFull() { - return total == 11; + return total == numbersArraySize - 1; } protected int peekaboo() { From 19eb9e85a79cbdc4a8787117af362297dfe5d4ac Mon Sep 17 00:00:00 2001 From: DisturbedCherry Date: Mon, 6 May 2024 11:10:23 +0200 Subject: [PATCH 10/22] 8) dodano @Override przy metodzie countIn w HanoiRhymer --- src/main/java/edu/kis/vh/nursery/HanoiRhymer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java b/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java index 89ffa912..25ea2f84 100644 --- a/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java @@ -8,6 +8,7 @@ public int reportRejected() { return totalRejected; } + @Override public void countIn(int in) { if (!callCheck() && in > peekaboo()) totalRejected++; From 94662ef9344558b5dc7eff8043e452eecb098eec Mon Sep 17 00:00:00 2001 From: DisturbedCherry Date: Mon, 6 May 2024 11:43:13 +0200 Subject: [PATCH 11/22] Corrected changes for my boss uwu --- .../kis/vh/nursery/DefaultCountingOutRhymer.java | 13 +++++++------ .../java/edu/kis/vh/nursery/list/IntLinkedList.java | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java index 6799a7f2..a7651212 100644 --- a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java @@ -3,10 +3,11 @@ public class DefaultCountingOutRhymer { public static final int numbersArraySize = 12; - public static int totalSize = -1; + public static final int totalInitSize = -1; + public static final int returnValue = -1; private int[] numbers = new int[numbersArraySize]; - public int total = totalSize; + public int total = totalInitSize; public void countIn(int in) { if (!isFull()) @@ -14,22 +15,22 @@ public void countIn(int in) { } public boolean callCheck() { - return total == totalSize; + return total == totalInitSize; } public boolean isFull() { - return total == numbersArraySize - 1; + return total == numbersArraySize + totalInitSize; } protected int peekaboo() { if (callCheck()) - return -1; + return returnValue; return numbers[total]; } public int countOut() { if (callCheck()) - return -1; + return returnValue; return numbers[total--]; } diff --git a/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java b/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java index 07efc0a2..7aecfccb 100644 --- a/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java +++ b/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java @@ -2,6 +2,7 @@ public class IntLinkedList { + public static final int returnValue = -1; Node last; int i; @@ -25,13 +26,13 @@ public boolean isFull() { public int top() { if (isEmpty()) - return -1; + return returnValue; return last.value; } public int pop() { if (isEmpty()) - return -1; + return returnValue; int ret = last.value; last = last.prev; return ret; From 871a5378d29edba39e8e66f0d6c15a299ff04de8 Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Sat, 11 May 2024 09:59:37 +0200 Subject: [PATCH 12/22] =?UTF-8?q?Zastosowanie=20najmniejszej=20mo=C5=BCliw?= =?UTF-8?q?ej=20widoczn=C5=9Bci=20w=20atrybutach=20klas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vh/nursery/DefaultCountingOutRhymer.java | 20 +++++++++---------- .../java/edu/kis/vh/nursery/FIFORhymer.java | 4 ++-- .../java/edu/kis/vh/nursery/HanoiRhymer.java | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java index a7651212..73e788e8 100644 --- a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java @@ -2,12 +2,12 @@ public class DefaultCountingOutRhymer { - public static final int numbersArraySize = 12; - public static final int totalInitSize = -1; - public static final int returnValue = -1; - private int[] numbers = new int[numbersArraySize]; + private static final int NUMBERS_ARRAY_SIZE = 12; + private static final int TOTAL_INIT_SIZE = -1; + private static final int RETURN_VALUE = -1; + private int[] numbers = new int[NUMBERS_ARRAY_SIZE]; - public int total = totalInitSize; + private int total = TOTAL_INIT_SIZE; public void countIn(int in) { if (!isFull()) @@ -15,23 +15,23 @@ public void countIn(int in) { } public boolean callCheck() { - return total == totalInitSize; + return total == TOTAL_INIT_SIZE; } public boolean isFull() { - return total == numbersArraySize + totalInitSize; + return total == NUMBERS_ARRAY_SIZE + TOTAL_INIT_SIZE; } protected int peekaboo() { if (callCheck()) - return returnValue; + return RETURN_VALUE; return numbers[total]; } public int countOut() { if (callCheck()) - return returnValue; + return RETURN_VALUE; return numbers[total--]; } -} +} \ No newline at end of file diff --git a/src/main/java/edu/kis/vh/nursery/FIFORhymer.java b/src/main/java/edu/kis/vh/nursery/FIFORhymer.java index b4688b4e..1edb6d5a 100644 --- a/src/main/java/edu/kis/vh/nursery/FIFORhymer.java +++ b/src/main/java/edu/kis/vh/nursery/FIFORhymer.java @@ -2,7 +2,7 @@ public class FIFORhymer extends DefaultCountingOutRhymer { - public DefaultCountingOutRhymer temp = new DefaultCountingOutRhymer(); + private DefaultCountingOutRhymer temp = new DefaultCountingOutRhymer(); @Override public int countOut() { @@ -18,4 +18,4 @@ public int countOut() { return ret; } -} +} \ No newline at end of file diff --git a/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java b/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java index 25ea2f84..c37053d1 100644 --- a/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java @@ -2,9 +2,9 @@ public class HanoiRhymer extends DefaultCountingOutRhymer { - int totalRejected = 0; + private int totalRejected = 0; - public int reportRejected() { + private int reportRejected() { return totalRejected; } From 8216ae341311218542e0cd2d74811079a7659d68 Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Sat, 11 May 2024 10:04:27 +0200 Subject: [PATCH 13/22] Wygenerowanie getter dla pola total --- .../java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java index 73e788e8..be5a3fa9 100644 --- a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java @@ -7,6 +7,10 @@ public class DefaultCountingOutRhymer { private static final int RETURN_VALUE = -1; private int[] numbers = new int[NUMBERS_ARRAY_SIZE]; + public int getTotal() { + return total; + } + private int total = TOTAL_INIT_SIZE; public void countIn(int in) { From 025e67be6bac8d441f22eee2dee390106fccdc3c Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Sat, 11 May 2024 10:13:09 +0200 Subject: [PATCH 14/22] Dokonanie hermetyzacji --- src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java index be5a3fa9..162a609f 100644 --- a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java @@ -38,4 +38,7 @@ public int countOut() { return numbers[total--]; } + public void setTotal(int total) { + this.total = total; + } } \ No newline at end of file From 96e6e763bdcb484aa74c81d7c921b4fbf21cb7e1 Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Sat, 11 May 2024 10:13:54 +0200 Subject: [PATCH 15/22] =?UTF-8?q?usuni=C4=99cie=20nie=20u=C5=BCywanych=20s?= =?UTF-8?q?etter=C3=B3w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java index 162a609f..be5a3fa9 100644 --- a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java @@ -38,7 +38,4 @@ public int countOut() { return numbers[total--]; } - public void setTotal(int total) { - this.total = total; - } } \ No newline at end of file From d21524812222b2f16551ecbc2caf658e34e4289d Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 27 May 2024 10:39:25 +0200 Subject: [PATCH 16/22] =?UTF-8?q?13.=20Uporz=C4=85dkuj=20aplikacj=C4=99=20?= =?UTF-8?q?demo=20RhymersDemo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/edu/kis/vh/nursery/RhymersDemo.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/test/java/edu/kis/vh/nursery/RhymersDemo.java b/src/test/java/edu/kis/vh/nursery/RhymersDemo.java index b854e2ee..63852077 100644 --- a/src/test/java/edu/kis/vh/nursery/RhymersDemo.java +++ b/src/test/java/edu/kis/vh/nursery/RhymersDemo.java @@ -7,27 +7,28 @@ class RhymersDemo { public static void main(String[] args) { Rhymersfactory factory = new DefaultRhymersFactory(); - + testRhymers(factory); + } + + private static void testRhymers(Rhymersfactory factory) { DefaultCountingOutRhymer[] rhymers = { factory.getStandardRhymer(), factory.getFalseRhymer(), factory.getFIFORhymer(), factory.getHanoiRhymer()}; - + for (int i = 1; i < 15; i++) for (int j = 0; j < 3; j++) rhymers[j].countIn(i); - + java.util.Random rn = new java.util.Random(); for (int i = 1; i < 15; i++) rhymers[3].countIn(rn.nextInt(20)); - + for (int i = 0; i < rhymers.length; i++) { while (!rhymers[i].callCheck()) System.out.print(rhymers[i].countOut() + " "); System.out.println(); } - + System.out.println("total rejected is " + ((HanoiRhymer) rhymers[3]).reportRejected()); - } - -} \ No newline at end of file +} From acaace9800ae98909acf209f384dd7862b6b0ffc Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 27 May 2024 10:49:14 +0200 Subject: [PATCH 17/22] Dokonaj refaktoryzacji IntLinkedList, aby uwzgldnil Node jako prywatna klase wewntrzna --- .../java/edu/kis/vh/nursery/list/IntLinkedList.java | 13 +++++++++++-- src/main/java/edu/kis/vh/nursery/list/Node.java | 12 ------------ 2 files changed, 11 insertions(+), 14 deletions(-) delete mode 100644 src/main/java/edu/kis/vh/nursery/list/Node.java diff --git a/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java b/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java index 7aecfccb..a1d86b37 100644 --- a/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java +++ b/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java @@ -3,8 +3,8 @@ public class IntLinkedList { public static final int returnValue = -1; - Node last; - int i; + private Node last; + private int i; public void push(int i) { if (last == null) @@ -38,4 +38,13 @@ public int pop() { return ret; } + private class Node { + private int value; + private Node prev, next; + + private Node(int i) { + value = i; + } + } + } diff --git a/src/main/java/edu/kis/vh/nursery/list/Node.java b/src/main/java/edu/kis/vh/nursery/list/Node.java deleted file mode 100644 index 1704f3ce..00000000 --- a/src/main/java/edu/kis/vh/nursery/list/Node.java +++ /dev/null @@ -1,12 +0,0 @@ -package edu.kis.vh.nursery.list; - -public class Node { - - public int value; - public Node prev, next; - - public Node(int i) { - value = i; - } - -} From 0e79b0fd0f7bfc51e0db9b56b4efaa0b891ecb46 Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 27 May 2024 10:53:09 +0200 Subject: [PATCH 18/22] =?UTF-8?q?15.=20zmiana=20reportRejected=20z=20prywa?= =?UTF-8?q?tnej=20-=20testy=20dzia=C5=82aj=C4=85=20po=20zmianie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/edu/kis/vh/nursery/HanoiRhymer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java b/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java index c37053d1..d78d3fbb 100644 --- a/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/HanoiRhymer.java @@ -4,7 +4,7 @@ public class HanoiRhymer extends DefaultCountingOutRhymer { private int totalRejected = 0; - private int reportRejected() { + int reportRejected() { return totalRejected; } From a81bffc51e067dd189ad78c3d93240b11fa364ed Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 27 May 2024 10:56:20 +0200 Subject: [PATCH 19/22] =?UTF-8?q?16.Dodanie=20test=C3=B3w=20dla=20klasy=20?= =?UTF-8?q?IntLinkedList?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vh/nursery/list/IntLinkedListTest.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/main/java/edu/kis/vh/nursery/list/IntLinkedListTest.java diff --git a/src/main/java/edu/kis/vh/nursery/list/IntLinkedListTest.java b/src/main/java/edu/kis/vh/nursery/list/IntLinkedListTest.java new file mode 100644 index 00000000..5d6b463c --- /dev/null +++ b/src/main/java/edu/kis/vh/nursery/list/IntLinkedListTest.java @@ -0,0 +1,56 @@ +package edu.kis.vh.nursery.list; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +public class IntLinkedListTest { + + @Test + public void testPush() { + IntLinkedList list = new IntLinkedList(); + assertTrue(list.isEmpty(), "List should be empty initially"); + + list.push(10); + assertFalse(list.isEmpty(), "List should not be empty after pushing an element"); + assertEquals(10, list.top(), "Top element should be 10"); + } + + @Test + public void testIsEmpty() { + IntLinkedList list = new IntLinkedList(); + assertTrue(list.isEmpty(), "List should be empty initially"); + + list.push(10); + assertFalse(list.isEmpty(), "List should not be empty after pushing an element"); + } + + @Test + public void testIsFull() { + IntLinkedList list = new IntLinkedList(); + assertFalse(list.isFull(), "List should never be full"); + } + + @Test + public void testTop() { + IntLinkedList list = new IntLinkedList(); + assertEquals(IntLinkedList.returnValue, list.top(), "Top of an empty list should return returnValue"); + + list.push(10); + assertEquals(10, list.top(), "Top element should be 10"); + + list.push(20); + assertEquals(20, list.top(), "Top element should be 20"); + } + + @Test + public void testPop() { + IntLinkedList list = new IntLinkedList(); + assertEquals(IntLinkedList.returnValue, list.pop(), "Pop from an empty list should return returnValue"); + + list.push(10); + list.push(20); + assertEquals(20, list.pop(), "Popped element should be 20"); + assertEquals(10, list.pop(), "Popped element should be 10"); + assertEquals(IntLinkedList.returnValue, list.pop(), "Pop from an empty list should return returnValue"); + } +} From ebee079789d63af441bf3416aa62941070666b18 Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 27 May 2024 10:56:51 +0200 Subject: [PATCH 20/22] =?UTF-8?q?16.Dodanie=20import=C3=B3w=20wykorzystany?= =?UTF-8?q?ch=20w=20IntLinkedListTest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index df6458d1..65a309bc 100644 --- a/pom.xml +++ b/pom.xml @@ -29,5 +29,11 @@ 4.12 test - + + org.junit.jupiter + junit-jupiter + RELEASE + compile + + \ No newline at end of file From 67c94472c1b4db397a3235b25921351c096e73b1 Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 27 May 2024 11:03:19 +0200 Subject: [PATCH 21/22] 17.Dodanie dokumentacji dla IntLinkedList --- .../kis/vh/nursery/list/IntLinkedList.java | 67 ++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java b/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java index a1d86b37..6ee306c7 100644 --- a/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java +++ b/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java @@ -1,11 +1,33 @@ package edu.kis.vh.nursery.list; +/** + * The IntLinkedList class represents a doubly linked list of integers. + * It supports basic operations such as push, pop, and checking if the list is empty or full. + */ public class IntLinkedList { + /** + * The constant value returned when an operation fails. + */ public static final int returnValue = -1; + + /** + * The last node in the linked list. + */ private Node last; + + /** + * An integer used for various purposes (currently unused). + */ private int i; + /** + * Pushes a new integer onto the top of the linked list. + * If the list is empty, creates a new node as the last element. + * Otherwise, adds the new node to the end of the list. + * + * @param i the integer to be added to the list + */ public void push(int i) { if (last == null) last = new Node(i); @@ -16,20 +38,43 @@ public void push(int i) { } } + /** + * Checks if the linked list is empty. + * + * @return true if the list is empty, false otherwise + */ public boolean isEmpty() { return last == null; } + /** + * Checks if the linked list is full. + * This implementation always returns false since the list is dynamically sized. + * + * @return false always, as the list cannot be full + */ public boolean isFull() { return false; } + /** + * Returns the value of the last element in the list without removing it. + * If the list is empty, returns returnValue. + * + * @return the value of the last element, or returnValue if the list is empty + */ public int top() { if (isEmpty()) return returnValue; return last.value; } + /** + * Removes and returns the value of the last element in the list. + * If the list is empty, returns returnValue. + * + * @return the value of the last element, or returnValue if the list is empty + */ public int pop() { if (isEmpty()) return returnValue; @@ -38,10 +83,30 @@ public int pop() { return ret; } + /** + * The Node class represents a node in a doubly linked list. + */ private class Node { + /** + * The value stored in the node. + */ private int value; - private Node prev, next; + /** + * A reference to the previous node in the list. + */ + private Node prev; + + /** + * A reference to the next node in the list. + */ + private Node next; + + /** + * Creates a new node with the specified value. + * + * @param i the value to be stored in the node + */ private Node(int i) { value = i; } From 40a4b1ece02a9a8bf24f1a9e201bc40ce3f3090f Mon Sep 17 00:00:00 2001 From: 235909 <245826@edu.p.lodz.pl> Date: Mon, 27 May 2024 11:15:42 +0200 Subject: [PATCH 22/22] =?UTF-8?q?18.=20dodaj=20notk=C4=99=20=E2=80=9ETODO:?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java | 2 +- src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java | 2 ++ src/test/java/edu/kis/vh/nursery/RhymersJUnitTest.java | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java index be5a3fa9..b02cdad2 100644 --- a/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java +++ b/src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java @@ -6,7 +6,7 @@ public class DefaultCountingOutRhymer { private static final int TOTAL_INIT_SIZE = -1; private static final int RETURN_VALUE = -1; private int[] numbers = new int[NUMBERS_ARRAY_SIZE]; - + // TODO: Move getTotal() method below the total variable declaration for better readability public int getTotal() { return total; } diff --git a/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java b/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java index 6ee306c7..a2115add 100644 --- a/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java +++ b/src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java @@ -19,6 +19,8 @@ public class IntLinkedList { /** * An integer used for various purposes (currently unused). */ + + // TODO: Remove unused variable 'i' if it's not needed in the future private int i; /** diff --git a/src/test/java/edu/kis/vh/nursery/RhymersJUnitTest.java b/src/test/java/edu/kis/vh/nursery/RhymersJUnitTest.java index f0f88d99..330ee112 100644 --- a/src/test/java/edu/kis/vh/nursery/RhymersJUnitTest.java +++ b/src/test/java/edu/kis/vh/nursery/RhymersJUnitTest.java @@ -8,6 +8,7 @@ public class RhymersJUnitTest { @Test public void testCountIn() { DefaultCountingOutRhymer rhymer = new DefaultCountingOutRhymer(); + // TODO: Change the constant name to uppercase int testValue = 4; rhymer.countIn(testValue); @@ -48,7 +49,7 @@ public void testPeekaboo() { int result = rhymer.peekaboo(); Assert.assertEquals(EMPTY_STACK_VALUE, result); - + // TODO: Change the constant name to uppercase and change the name to make it easier to analyze the code int testValue = 4; rhymer.countIn(testValue); @@ -65,7 +66,7 @@ public void testCountOut() { int result = rhymer.countOut(); Assert.assertEquals(EMPTY_STACK_VALUE, result); - + // TODO: Change the constant name to uppercase and change the name to make it easier to analyze the code int testValue = 4; rhymer.countIn(testValue);