Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
|
1e948c6ef3 | |
|
7e016fafdf |
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package de.th_mannheim.informatik.blackjack.facade.dtos;
|
||||
|
||||
import de.th_mannheim.informatik.blackjack.domain.Card;
|
||||
|
||||
// Records sind "immutable data classes", die seit Version 14 verfügbar sind.
|
||||
// Sie benötigen nur die Angaben der gewünschten Attribute, auf die per Punkt-Notation
|
||||
// zugegriffen werden kann.
|
||||
|
||||
public record CardDTO(String name, int points) {
|
||||
public CardDTO(Card card) {
|
||||
this(card.toString(), card.getPoints());
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue