Added package structure

Sorted the classes in different packages
master
Victor Hans-Georg Waitz 2024-03-26 11:58:41 +01:00
parent ed299fbf16
commit 386aa44016
6 changed files with 28 additions and 8 deletions

View File

@ -1,3 +1,7 @@
package TUI;
import facade.BlackJackSpiel;
import java.util.Scanner; import java.util.Scanner;
public class Main { public class Main {
@ -13,7 +17,6 @@ public class Main {
private static void gameLoop(){ private static void gameLoop(){
BlackJackSpiel game = new BlackJackSpiel(); BlackJackSpiel game = new BlackJackSpiel();
// Hand hand = game.getNeueHand();
while (true){ while (true){
System.out.printf("%s Ihr Wert beträgt %d \n", game.handContent(), game.handValue()); System.out.printf("%s Ihr Wert beträgt %d \n", game.handContent(), game.handValue());

View File

@ -1,3 +1,7 @@
package domain;
import domain.Karte;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
@ -65,7 +69,7 @@ public class Hand {
@Override @Override
public String toString() { public String toString() {
if (hand.isEmpty()){ if (hand.isEmpty()){
return "Hand ist leer."; return "domain.Hand ist leer.";
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

View File

@ -1,6 +1,8 @@
package domain;
public class Karte { public class Karte {
String farbe; public String farbe;
String wert; public String wert;
public Karte(String farbe, String wert) { public Karte(String farbe, String wert) {
this.farbe = farbe; this.farbe = farbe;

View File

@ -1,9 +1,13 @@
package domain;
import domain.Karte;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random; import java.util.Random;
public class Kartenstapel { public class Kartenstapel {
private ArrayList<Karte> stapel = new ArrayList<>(); private ArrayList<Karte> stapel = new ArrayList<>();
Kartenstapel(){ public Kartenstapel(){
stapel = generateNewStapel(); stapel = generateNewStapel();
} }

View File

@ -1,3 +1,8 @@
package facade;
import domain.Hand;
import domain.Kartenstapel;
public class BlackJackSpiel { public class BlackJackSpiel {
Kartenstapel ks; Kartenstapel ks;
private Hand hand; private Hand hand;
@ -21,16 +26,16 @@ public class BlackJackSpiel {
// return this.hand; // return this.hand;
} }
void turn(){ public void turn(){
this.hand.drawCard(1); this.hand.drawCard(1);
// return this.hand; // return this.hand;
} }
String handContent(){ public String handContent(){
return hand.toString(); return hand.toString();
} }
int handValue(){ public int handValue(){
return hand.getPunkte(); return hand.getPunkte();
} }
} }

View File

@ -1,3 +1,5 @@
import domain.Karte;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
class KarteTest { class KarteTest {