started UC-gameplay-15

This commit is contained in:
Johannes Schmelz 2024-11-12 22:34:46 +01:00
parent dca23151a8
commit 65c85aacf0
2 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package pp.monopoly.model.card;
public class Card {
private final String description;
private final String keyword;
Card(String description, String keyword) {
this.description = description;
this.keyword = keyword;
}
public void accept(DeckHelper visitor) {
visitor.visit(this);
}
String getDescription() {
return description;
}
String getKeyword() {
return keyword;
}
}

View File

@ -0,0 +1,34 @@
package pp.monopoly.model.card;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Queue;
import pp.monopoly.model.CardVisitor;
public class DeckHelper implements CardVisitor<Void>{
private static Queue<Card> cards;
private DeckHelper() {
}
@Override
public Void visit(Card c) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'visit'");
}
private void shuffle() {
List<Card> cardList = new ArrayList<>(cards);
Collections.shuffle(cardList);
cards.clear();
cards.addAll(cardList);
}
public static Card drawCard() {
return cards != null ? cards.poll() : null;
}
}