diff --git a/Test/src/BlackJack.java b/Test/src/BlackJack.java index 7c82c14..9db04c1 100644 --- a/Test/src/BlackJack.java +++ b/Test/src/BlackJack.java @@ -1,12 +1,19 @@ public class BlackJack { - private Hand hand; + public Hand hand; + public CardStack cs; public BlackJack() { - hand = new Hand(new CardStack()); + cs = new CardStack(); + hand = new Hand(cs); } public Hand get_new_hand() { - hand = new Hand(new CardStack()); + hand = new Hand(cs); return hand; } + + @Override + public String toString() { + return hand.toString(); + } } diff --git a/Test/src/Hand.java b/Test/src/Hand.java index a87037a..95ca208 100644 --- a/Test/src/Hand.java +++ b/Test/src/Hand.java @@ -12,7 +12,14 @@ public class Hand { } public String toString() { - return "al;skdjf;alskdjfsa;lkjfd;lkaj hier die hand beschreiben also 5 karo, ... insgesamt 15"; + String return_message = "Die Karten sind: "; + + for (Card card : current_hand) { + System.out.print(card.card_value + " , " + card.color + " , "); + } + + System.out.println("Insgesamt sind dies " + Integer.toString(get_points()) + " Punkte"); + return return_message; } public int get_points() { diff --git a/Test/src/TUI.java b/Test/src/TUI.java index 3b93a15..6186528 100644 --- a/Test/src/TUI.java +++ b/Test/src/TUI.java @@ -1,16 +1,38 @@ +import java.util.Scanner; + public class TUI { public BlackJack bs; + Scanner sc = new Scanner(System.in); public TUI() { bs = new BlackJack(); game_loop(); + } + //TODO Ass und Exception + JUnit public void game_loop() { + System.out.println(bs); while (true) { + System.out.println("Weitere Karte Ziehen (1)"); + System.out.println("Karten so belassen (2)"); + + String answer = sc.nextLine(); + if (answer.equals("2")) { + break; + } + + bs.cs.draw_card(); + + if (bs.hand.get_points() == 21) { + System.out.println("Gut gemacht"); + break; + } } + + System.out.println(bs); } }