Esempio n. 1
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);
   }
 }
Esempio n. 2
0
 /* Inicializa as 7 pilhas, distribuindo as cartas recebidas pelas 7 pilhas.
  *
  */
 public ZonaC(StackArray<Carta> l) throws GameException {
   try {
     pilhas = new DoubleLinkedList[7];
     for (int i = 0; i < 7; i++) {
       pilhas[i] = new DoubleLinkedList<Carta>();
     }
     // distribuir as cartas
     for (int i = 0; i < 7; i++) {
       // adicionar cartas viradas para baixo
       for (int j = 0; j < i; j++) {
         pilhas[i].add(l.pop());
       }
       Carta c = l.pop();
       c.setVoltadaParaCima(true);
       pilhas[i].add(c);
     }
   } catch (StackIsEmptyException e) {
     throw new GameException(GameException.GAME_EXCEPTION_WITHOUT_ENOUGH_CARDS);
   }
 }