Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FinalDeck {
- Card topCard;
- public FinalDeck() {
- topCard = null;
- }
- public boolean add(Card card) {
- if (topCard == null) {
- if (card.getValue() == 1) {
- topCard = card;
- return true;
- }
- } else if (topCard.getType() == card.getType() && topCard.getValue() + 1 == card.getValue()) {
- topCard = card;
- return true;
- }
- return false;
- }
- // move card to Temp deck
- public boolean moveToTemp(Column tempDeck) {
- if (topCard != null) {
- if (tempDeck.add(topCard)) {
- this.removeTop();
- return true;
- }
- }
- return false;
- }
- private void removeTop() {
- if (topCard != null) {
- if (topCard.getValue() == 1)
- topCard = null;
- else
- topCard = new Card(topCard.getType(), topCard.getValue() - 1);
- }
- }
- public boolean isFull() {
- if (topCard == null)
- return false;
- return topCard.getValue() == 13;
- }
- @Override
- public String toString() {
- if (topCard == null)
- return " ";
- return "[" + topCard.toString() + "]";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement