mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-24 21:39:44 +01:00
started UC-gameplay-15
This commit is contained in:
parent
dca23151a8
commit
65c85aacf0
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user