wiso vergisst man so viel

main
Luc Vonnemann 2024-03-25 19:59:35 +01:00
parent 804494b849
commit 8c0e89011c
3 changed files with 40 additions and 4 deletions

View File

@ -1,12 +1,19 @@
public class BlackJack { public class BlackJack {
private Hand hand; public Hand hand;
public CardStack cs;
public BlackJack() { public BlackJack() {
hand = new Hand(new CardStack()); cs = new CardStack();
hand = new Hand(cs);
} }
public Hand get_new_hand() { public Hand get_new_hand() {
hand = new Hand(new CardStack()); hand = new Hand(cs);
return hand; return hand;
} }
@Override
public String toString() {
return hand.toString();
}
} }

View File

@ -12,7 +12,14 @@ public class Hand {
} }
public String toString() { 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() { public int get_points() {

View File

@ -1,16 +1,38 @@
import java.util.Scanner;
public class TUI { public class TUI {
public BlackJack bs; public BlackJack bs;
Scanner sc = new Scanner(System.in);
public TUI() { public TUI() {
bs = new BlackJack(); bs = new BlackJack();
game_loop(); game_loop();
} }
//TODO Ass und Exception + JUnit
public void game_loop() { public void game_loop() {
System.out.println(bs);
while (true) { 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);
} }
} }