Exemplo n.º 1
0
  /**
   * Flips the faceup state of the topmost card on the BuildablePile.
   *
   * <p>Generates modelChanged action if BuildablePile is not empty.
   *
   * <p>
   *
   * @return boolean if able to flip the card on top of the BuildablePile
   */
  public boolean flipCard() {
    if (empty()) return false;

    Card c = get();
    c.setFaceUp(!c.isFaceUp());
    add(c);

    hasChanged(); // state has changed
    return true;
  }
Exemplo n.º 2
0
  /**
   * Return the number of cards in this BuildablePile that are face down.
   *
   * <p>
   *
   * @return int
   */
  public int getNumFaceDown() {
    int numFaceDown = 0;

    int ct = count();
    for (int i = 0; i < ct; i++) {
      Card c = peek(ct - i - 1);
      if (c.isFaceUp() == false) {
        numFaceDown++;
      }
    }

    return numFaceDown;
  }
Exemplo n.º 3
0
  /**
   * Returns whether the top of the BuildablePile is face up.
   *
   * <p>Note: an empty BuildablePile is returned as false
   *
   * <p>
   *
   * @return int
   */
  public boolean faceUp() {
    if (empty()) return false;

    Card c = peek();
    return c.isFaceUp();
  }