Advertisement
Guest User

Klasse Player

a guest
Jan 19th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. package de.uniwue.gdp.pdd;
  2.  
  3. import de.uniwue.gdp.pdd.deck.Card;
  4.  
  5. import java.util.ArrayList;
  6. import java.util.Collection;
  7. import java.util.List;
  8. import java.util.Optional;
  9. import java.util.function.BiPredicate;
  10.  
  11. public abstract class Player implements GameListener {
  12.  
  13. private final String name;
  14. protected final List<Card> hand;
  15.  
  16. protected Player(String name) {
  17. this.hand = new ArrayList<>();
  18. this.name = name;
  19. }
  20.  
  21. public void startNewGame(Collection<Card> hand) {
  22. this.hand.clear();
  23. this.hand.addAll(hand);
  24. }
  25.  
  26. public void take(Card card) {
  27. this.hand.add(card);
  28. }
  29.  
  30. public int numberOfCards() {
  31. return this.hand.size();
  32. }
  33.  
  34. public String name() {
  35. return this.name;
  36. }
  37.  
  38. public abstract BiPredicate<Card, Card> invent();
  39.  
  40. public abstract Optional<Card> play(Card top);
  41.  
  42. @Override
  43. public String toString() {
  44. return this.name();
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement