From 386aa44016b64561c5f02154295c2c0973a63d16 Mon Sep 17 00:00:00 2001 From: 3013050 <3013050@stud.hs-mannheim.de> Date: Tue, 26 Mar 2024 11:58:41 +0100 Subject: [PATCH] Added package structure Sorted the classes in different packages --- src/{ => TUI}/Main.java | 5 ++++- src/{ => domain}/Hand.java | 6 +++++- src/{ => domain}/Karte.java | 6 ++++-- src/{ => domain}/Kartenstapel.java | 6 +++++- src/{ => facade}/BlackJackSpiel.java | 11 ++++++++--- tests/KarteTest.java | 2 ++ 6 files changed, 28 insertions(+), 8 deletions(-) rename src/{ => TUI}/Main.java (98%) rename src/{ => domain}/Hand.java (95%) rename src/{ => domain}/Karte.java (88%) rename src/{ => domain}/Kartenstapel.java (95%) rename src/{ => facade}/BlackJackSpiel.java (80%) diff --git a/src/Main.java b/src/TUI/Main.java similarity index 98% rename from src/Main.java rename to src/TUI/Main.java index dd589eb..49bb7ab 100644 --- a/src/Main.java +++ b/src/TUI/Main.java @@ -1,3 +1,7 @@ +package TUI; + +import facade.BlackJackSpiel; + import java.util.Scanner; public class Main { @@ -13,7 +17,6 @@ public class Main { private static void gameLoop(){ BlackJackSpiel game = new BlackJackSpiel(); - // Hand hand = game.getNeueHand(); while (true){ System.out.printf("%s Ihr Wert betrÃĪgt %d \n", game.handContent(), game.handValue()); diff --git a/src/Hand.java b/src/domain/Hand.java similarity index 95% rename from src/Hand.java rename to src/domain/Hand.java index d5dd959..d97e626 100644 --- a/src/Hand.java +++ b/src/domain/Hand.java @@ -1,3 +1,7 @@ +package domain; + +import domain.Karte; + import java.util.ArrayList; import java.util.Objects; @@ -65,7 +69,7 @@ public class Hand { @Override public String toString() { if (hand.isEmpty()){ - return "Hand ist leer."; + return "domain.Hand ist leer."; } StringBuilder sb = new StringBuilder(); diff --git a/src/Karte.java b/src/domain/Karte.java similarity index 88% rename from src/Karte.java rename to src/domain/Karte.java index 01ee188..d035960 100644 --- a/src/Karte.java +++ b/src/domain/Karte.java @@ -1,6 +1,8 @@ +package domain; + public class Karte { - String farbe; - String wert; + public String farbe; + public String wert; public Karte(String farbe, String wert) { this.farbe = farbe; diff --git a/src/Kartenstapel.java b/src/domain/Kartenstapel.java similarity index 95% rename from src/Kartenstapel.java rename to src/domain/Kartenstapel.java index 6d0c953..2fc8a42 100644 --- a/src/Kartenstapel.java +++ b/src/domain/Kartenstapel.java @@ -1,9 +1,13 @@ +package domain; + +import domain.Karte; + import java.util.ArrayList; import java.util.Random; public class Kartenstapel { private ArrayList stapel = new ArrayList<>(); - Kartenstapel(){ + public Kartenstapel(){ stapel = generateNewStapel(); } diff --git a/src/BlackJackSpiel.java b/src/facade/BlackJackSpiel.java similarity index 80% rename from src/BlackJackSpiel.java rename to src/facade/BlackJackSpiel.java index 373ae7e..7fe4c1f 100644 --- a/src/BlackJackSpiel.java +++ b/src/facade/BlackJackSpiel.java @@ -1,3 +1,8 @@ +package facade; + +import domain.Hand; +import domain.Kartenstapel; + public class BlackJackSpiel { Kartenstapel ks; private Hand hand; @@ -21,16 +26,16 @@ public class BlackJackSpiel { // return this.hand; } - void turn(){ + public void turn(){ this.hand.drawCard(1); // return this.hand; } - String handContent(){ + public String handContent(){ return hand.toString(); } - int handValue(){ + public int handValue(){ return hand.getPunkte(); } } diff --git a/tests/KarteTest.java b/tests/KarteTest.java index 34afabb..55cc633 100644 --- a/tests/KarteTest.java +++ b/tests/KarteTest.java @@ -1,3 +1,5 @@ +import domain.Karte; + import static org.junit.jupiter.api.Assertions.*; class KarteTest {