Erstes DTO eingefügt

dtos
hummel 2025-04-01 22:58:52 +02:00
parent 93a2ef7342
commit 7e016fafdf
3 changed files with 18 additions and 5 deletions

View File

@ -1,7 +1,7 @@
package de.th_mannheim.informatik.blackjack.facade;
import de.th_mannheim.informatik.blackjack.domain.Card;
import de.th_mannheim.informatik.blackjack.domain.CardDeck;
import de.th_mannheim.informatik.blackjack.facade.dtos.CardDTO;
public class BlackjackGame {
private CardDeck deck;
@ -10,8 +10,8 @@ public class BlackjackGame {
this.deck = new CardDeck();
}
public Card getNextCard() {
return deck.getNextCard();
public CardDTO getNextCard() {
return new CardDTO(deck.getNextCard());
}
}

View File

@ -0,0 +1,13 @@
package de.th_mannheim.informatik.blackjack.facade.dtos;
import de.th_mannheim.informatik.blackjack.domain.Card;
public record CardDTO(String name, int points) {
public CardDTO(Card card) {
this(card.toString(), card.getPoints());
}
public String toString() {
return name;
}
}

View File

@ -7,11 +7,11 @@ public class GameMenu {
public GameMenu(BlackjackGame game) {
this.game = game;
System.out.println("Willkommen beim THMA Blackjack!");
}
public void show() {
System.out.println();
System.out.println("Ihre Karten sind: ");
System.out.println(game.getNextCard());