Esempio n. 1
0
  /**
   * Retorna uma carta aleatoria do baralho.
   *
   * @return Carta
   * @throws IndexOutOfBoundsException
   */
  public Carta get() throws IndexOutOfBoundsException {
    int index = randomizer.nextInt(baralho.size());
    Carta c = baralho.get(index);
    baralho.remove(index);

    return c;
  }
Esempio n. 2
0
 /**
  * Retorna uma pilha de n cartas.
  *
  * @param num
  * @return StackArray<Carta>
  * @throws GameException
  */
 public StackArray<Carta> getPilhaCartas(int num) throws GameException {
   try {
     StackArray<Carta> lista = new StackArray<Carta>(num);
     for (int i = 0; i < num; i++) {
       // lista.push(get());
       lista.push(baralho.get(0));
       baralho.remove(0);
     }
     return lista;
   } catch (Exception e) {
     throw new GameException(GameException.GAME_EXCEPTION_WITHOUT_ENOUGH_CARDS);
   }
 }