From 3d8644ebd735cc78d5c953b477898b5cb055f731 Mon Sep 17 00:00:00 2001 From: fdai7920 Date: Fri, 19 Jan 2024 11:52:41 +0100 Subject: [PATCH 1/6] update team.md fdai7920 --- team.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/team.md b/team.md index 7ea9273..9fd321b 100644 --- a/team.md +++ b/team.md @@ -1 +1,2 @@ -- fdai7736, fdai7736 \ No newline at end of file +- fdai7736, fdai7736 +- fdai7920, fdai7920 \ No newline at end of file From 8c1feda1552901fda261989a7e27d75cd4fd94f5 Mon Sep 17 00:00:00 2001 From: fdai7920 Date: Fri, 19 Jan 2024 14:23:51 +0100 Subject: [PATCH 2/6] Card Variables --- .../java/de/hsfulda/onses/models/Cards.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/de/hsfulda/onses/models/Cards.java diff --git a/src/main/java/de/hsfulda/onses/models/Cards.java b/src/main/java/de/hsfulda/onses/models/Cards.java new file mode 100644 index 0000000..59e5da4 --- /dev/null +++ b/src/main/java/de/hsfulda/onses/models/Cards.java @@ -0,0 +1,27 @@ +package de.hsfulda.onses.models; + +public class Cards { + + public enum ecolor { + RED, BLUE, GREEN, YELLOW, BLACK; + + private static final ecolor[] colors = ecolor.values(); + public static ecolor getColors (int n) + { + return ecolor.colors[n]; + } + }; + public enum evalue { + ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, DRAWTWO, SKIP, REVERSE, CHOOSE, CHOOSEDRAW; + + private static final evalue[] values = evalue.values(); + public static evalue getValue(int n) { + return evalue.values[n]; + } + }; + + private int id; + private ecolor color; + private evalue value; + +} From 7fbeacc0aa1dc5161da566c4a42ef8df3127bc8d Mon Sep 17 00:00:00 2001 From: fdai7920 Date: Fri, 19 Jan 2024 14:30:32 +0100 Subject: [PATCH 3/6] Test.CardsGetID --- .../java/de/hsfulda/onses/models/Cards.java | 19 +++++++++++-- src/test/java/de/hsfulda/onses/CardsTest.java | 28 +++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/test/java/de/hsfulda/onses/CardsTest.java diff --git a/src/main/java/de/hsfulda/onses/models/Cards.java b/src/main/java/de/hsfulda/onses/models/Cards.java index 59e5da4..e96f8f6 100644 --- a/src/main/java/de/hsfulda/onses/models/Cards.java +++ b/src/main/java/de/hsfulda/onses/models/Cards.java @@ -20,8 +20,21 @@ public class Cards { } }; - private int id; - private ecolor color; - private evalue value; + private final int id; + private final ecolor color; + private final evalue value; + + + public Cards(int id, ecolor color, evalue value) + { + this.id = id; + this.color = color; + this.value = value; + } + + + public int getId() { + return this.id; + } } diff --git a/src/test/java/de/hsfulda/onses/CardsTest.java b/src/test/java/de/hsfulda/onses/CardsTest.java new file mode 100644 index 0000000..d1d7daa --- /dev/null +++ b/src/test/java/de/hsfulda/onses/CardsTest.java @@ -0,0 +1,28 @@ + +package de.hsfulda.onses; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +import de.hsfulda.onses.models.Cards; + +public class CardsTest { + + @Test + @DisplayName("ModelCardsClass") + public void CardTestGetID5() { + + Cards testcard = new Cards(5, Cards.ecolor.BLACK, Cards.evalue.FIVE); + assertEquals(5, testcard.getId()); + } + @Test + @DisplayName("ModelCardsClass") + public void CardTestGetID112() { + + Cards testcard = new Cards(112, Cards.ecolor.BLUE, Cards.evalue.CHOOSEDRAW); + assertEquals(112, testcard.getId()); + } + + +} \ No newline at end of file From 826619b147af1205f4981c4ca857e5ed729d8d5d Mon Sep 17 00:00:00 2001 From: fdai7920 Date: Fri, 19 Jan 2024 14:36:24 +0100 Subject: [PATCH 4/6] Test.CardsGetColor --- .../java/de/hsfulda/onses/models/Cards.java | 4 ++++ src/test/java/de/hsfulda/onses/CardsTest.java | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/hsfulda/onses/models/Cards.java b/src/main/java/de/hsfulda/onses/models/Cards.java index e96f8f6..0326c85 100644 --- a/src/main/java/de/hsfulda/onses/models/Cards.java +++ b/src/main/java/de/hsfulda/onses/models/Cards.java @@ -37,4 +37,8 @@ public class Cards { return this.id; } + public ecolor getColor() { + return this.color; + } + } diff --git a/src/test/java/de/hsfulda/onses/CardsTest.java b/src/test/java/de/hsfulda/onses/CardsTest.java index d1d7daa..4eb4bcf 100644 --- a/src/test/java/de/hsfulda/onses/CardsTest.java +++ b/src/test/java/de/hsfulda/onses/CardsTest.java @@ -10,19 +10,34 @@ import de.hsfulda.onses.models.Cards; public class CardsTest { @Test - @DisplayName("ModelCardsClass") + @DisplayName("CardGetID5") public void CardTestGetID5() { Cards testcard = new Cards(5, Cards.ecolor.BLACK, Cards.evalue.FIVE); assertEquals(5, testcard.getId()); } @Test - @DisplayName("ModelCardsClass") + @DisplayName("CardGetID112") public void CardTestGetID112() { Cards testcard = new Cards(112, Cards.ecolor.BLUE, Cards.evalue.CHOOSEDRAW); assertEquals(112, testcard.getId()); } + @Test + @DisplayName("CardGetColorBlue") + public void CardTestGetColorBlue() { + + Cards testcard = new Cards(9, Cards.ecolor.BLUE, Cards.evalue.FIVE); + assertEquals(Cards.ecolor.BLUE, testcard.getColor()); + } + @Test + @DisplayName("CardGetColorBlack") + public void CardTestGetColorBlack() { + + Cards testcard = new Cards(15, Cards.ecolor.BLACK, Cards.evalue.CHOOSE); + assertEquals(Cards.ecolor.BLACK, testcard.getColor()); + } + } \ No newline at end of file From 7e750cd942065136bdc139cd321e776c16db822b Mon Sep 17 00:00:00 2001 From: fdai7920 Date: Fri, 19 Jan 2024 14:44:55 +0100 Subject: [PATCH 5/6] Test.CardsGetValue --- src/main/java/de/hsfulda/onses/models/Cards.java | 3 +++ src/test/java/de/hsfulda/onses/CardsTest.java | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/main/java/de/hsfulda/onses/models/Cards.java b/src/main/java/de/hsfulda/onses/models/Cards.java index 0326c85..d2aeb30 100644 --- a/src/main/java/de/hsfulda/onses/models/Cards.java +++ b/src/main/java/de/hsfulda/onses/models/Cards.java @@ -41,4 +41,7 @@ public class Cards { return this.color; } + public evalue getValue() { + return this.value; + } } diff --git a/src/test/java/de/hsfulda/onses/CardsTest.java b/src/test/java/de/hsfulda/onses/CardsTest.java index 4eb4bcf..eb133a2 100644 --- a/src/test/java/de/hsfulda/onses/CardsTest.java +++ b/src/test/java/de/hsfulda/onses/CardsTest.java @@ -24,6 +24,7 @@ public class CardsTest { assertEquals(112, testcard.getId()); } + @Test @DisplayName("CardGetColorBlue") public void CardTestGetColorBlue() { @@ -40,4 +41,19 @@ public class CardsTest { } + @Test + @DisplayName("CardGetValueThree") + public void CardTestGetValueThree() { + + Cards testcard = new Cards(2, Cards.ecolor.BLUE, Cards.evalue.THREE); + assertEquals(Cards.evalue.THREE, testcard.getValue()); + } + @Test + @DisplayName("CardGetValueSkip") + public void CardTestGetValueSkip() { + + Cards testcard = new Cards(19, Cards.ecolor.BLACK, Cards.evalue.SKIP); + assertEquals(Cards.evalue.SKIP, testcard.getValue()); + } + } \ No newline at end of file From b9be78a5d2d984ee31d7b435165493c12ce06549 Mon Sep 17 00:00:00 2001 From: fdai7920 Date: Fri, 19 Jan 2024 15:17:34 +0100 Subject: [PATCH 6/6] refactoring: betterTestStructure --- src/test/java/de/hsfulda/onses/CardsTest.java | 61 +++++++++++++++---- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/src/test/java/de/hsfulda/onses/CardsTest.java b/src/test/java/de/hsfulda/onses/CardsTest.java index eb133a2..ab7e6d7 100644 --- a/src/test/java/de/hsfulda/onses/CardsTest.java +++ b/src/test/java/de/hsfulda/onses/CardsTest.java @@ -13,15 +13,28 @@ public class CardsTest { @DisplayName("CardGetID5") public void CardTestGetID5() { - Cards testcard = new Cards(5, Cards.ecolor.BLACK, Cards.evalue.FIVE); - assertEquals(5, testcard.getId()); + // arrange + int expected = 5; + int ID = 5; + // act + Cards testcard = new Cards(ID, Cards.ecolor.BLACK, Cards.evalue.FIVE); + int answer = testcard.getId(); + // assert + assertEquals(expected, answer); } + @Test @DisplayName("CardGetID112") public void CardTestGetID112() { - Cards testcard = new Cards(112, Cards.ecolor.BLUE, Cards.evalue.CHOOSEDRAW); - assertEquals(112, testcard.getId()); + // arrange + int expected = 112; + int ID = 112; + // act + Cards testcard = new Cards(ID, Cards.ecolor.BLUE, Cards.evalue.CHOOSEDRAW); + int answer = testcard.getId(); + // assert + assertEquals(expected, answer); } @@ -29,15 +42,27 @@ public class CardsTest { @DisplayName("CardGetColorBlue") public void CardTestGetColorBlue() { - Cards testcard = new Cards(9, Cards.ecolor.BLUE, Cards.evalue.FIVE); - assertEquals(Cards.ecolor.BLUE, testcard.getColor()); + // arrange + Cards.ecolor expected = Cards.ecolor.BLUE; + Cards.ecolor color = Cards.ecolor.BLUE; + // act + Cards testcard = new Cards(9, color, Cards.evalue.FIVE); + Cards.ecolor answer = testcard.getColor(); + // assert + assertEquals(expected, answer); } @Test @DisplayName("CardGetColorBlack") public void CardTestGetColorBlack() { - Cards testcard = new Cards(15, Cards.ecolor.BLACK, Cards.evalue.CHOOSE); - assertEquals(Cards.ecolor.BLACK, testcard.getColor()); + // arrange + Cards.ecolor expected = Cards.ecolor.BLACK; + Cards.ecolor color = Cards.ecolor.BLACK; + // act + Cards testcard = new Cards(15, color, Cards.evalue.CHOOSE); + Cards.ecolor answer = testcard.getColor(); + // assert + assertEquals(expected, answer); } @@ -45,15 +70,27 @@ public class CardsTest { @DisplayName("CardGetValueThree") public void CardTestGetValueThree() { - Cards testcard = new Cards(2, Cards.ecolor.BLUE, Cards.evalue.THREE); - assertEquals(Cards.evalue.THREE, testcard.getValue()); + // arrange + Cards.evalue expected = Cards.evalue.THREE; + Cards.evalue value = Cards.evalue.THREE; + // act + Cards testcard = new Cards(2, Cards.ecolor.BLUE, value); + Cards.evalue answer = testcard.getValue(); + // assert + assertEquals(expected, answer); } @Test @DisplayName("CardGetValueSkip") public void CardTestGetValueSkip() { - Cards testcard = new Cards(19, Cards.ecolor.BLACK, Cards.evalue.SKIP); - assertEquals(Cards.evalue.SKIP, testcard.getValue()); + // arrange + Cards.evalue expected = Cards.evalue.SKIP; + Cards.evalue value = Cards.evalue.SKIP; + // act + Cards testcard = new Cards(19, Cards.ecolor.BLACK, value); + Cards.evalue answer = testcard.getValue(); + // assert + assertEquals(expected, answer); } } \ No newline at end of file