From ebea25804413d5f35d1d4f0b6c8f4d5805cc1207 Mon Sep 17 00:00:00 2001 From: lucvo <3012946@stud.hs-mannheim.de> Date: Mon, 25 Mar 2024 20:30:23 +0100 Subject: [PATCH] bug hunt anfang --- Test/src/CardStack.java | 6 +++--- Test/src/Hand.java | 8 +++++--- Test/src/TUI.java | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Test/src/CardStack.java b/Test/src/CardStack.java index 44acc65..71206ef 100644 --- a/Test/src/CardStack.java +++ b/Test/src/CardStack.java @@ -7,13 +7,13 @@ public class CardStack { private int[] random_place = new int[52]; private final String[] card_values = {"Ass", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Bube", "Dame", "King"}; private final String[] card_colors = {"Piek", "Kreuz", "Karo", "Herz"}; - private int card_draw_counter = 0; + public int card_draw_counter = 0; public CardStack() { int next_place; - for (int i = 1; i <= 13; i++) { - for (int j = 1; j <= 4; j++) { + for (int i = 0; i < 13; i++) { + for (int j = 0; j < 4; j++) { next_place = get_place(); shuffled_cards[next_place] = get_card(card_values[i], card_colors[j]); } diff --git a/Test/src/Hand.java b/Test/src/Hand.java index 95ca208..05d1a6e 100644 --- a/Test/src/Hand.java +++ b/Test/src/Hand.java @@ -14,8 +14,9 @@ public class Hand { public String toString() { String return_message = "Die Karten sind: "; - for (Card card : current_hand) { - System.out.print(card.card_value + " , " + card.color + " , "); + for (int i = 0; i < cs.card_draw_counter; i++) { + Card card = current_hand[i]; + System.out.print(card.card_value + " in " + card.color + " , "); } System.out.println("Insgesamt sind dies " + Integer.toString(get_points()) + " Punkte"); @@ -25,7 +26,8 @@ public class Hand { public int get_points() { int sum = 0; - for (Card card : current_hand) { + for (int i = 0; i < cs.card_draw_counter; i++) { + Card card = current_hand[i]; sum += card.get_points(card); } diff --git a/Test/src/TUI.java b/Test/src/TUI.java index 6186528..a009594 100644 --- a/Test/src/TUI.java +++ b/Test/src/TUI.java @@ -11,7 +11,7 @@ public class TUI { } - //TODO Ass und Exception + JUnit + //TODO Ass und Exception + JUnit + new_hand public void game_loop() { System.out.println(bs);