Guest User

Untitled

a guest
Apr 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.88 KB | None | 0 0
  1. public class Carta {
  2.     static final int VALOR_AS = 1;
  3.     static final int VALOR_2 = 2;
  4.     static final int VALOR_3 = 3;
  5.     static final int VALOR_4 = 4;
  6.     static final int VALOR_5 = 5;
  7.     static final int VALOR_6 = 6;
  8.     static final int VALOR_7 = 7;
  9.     static final int VALOR_8 = 8;
  10.     static final int VALOR_9 = 9;
  11.     static final int VALOR_10 = 10;
  12.     static final int VALOR_VALETE = 11;
  13.     static final int VALOR_RAINHA = 12;
  14.     static final int VALOR_REI = 13;
  15.  
  16.     static final int NAIPE_COPAS = 0;
  17.     static final int NAIPE_PAUS = 1;
  18.     static final int NAIPE_OUROS = 2;
  19.     static final int NAIPE_ESPADAS = 3;
  20.  
  21.     static final int NAIPECOR_PRETO = 0;
  22.     static final int NAIPECOR_VERMELHO = 1;
  23.  
  24.     final private int naipe;
  25.     final private int naipeCor;
  26.     final private int valor;
  27.     private boolean paraCima = false;
  28.  
  29.     Carta(int naipe, int valor) {
  30.         this.naipe = naipe;
  31.         switch (this.naipe) {
  32.         case NAIPE_COPAS:
  33.             this.naipeCor = NAIPECOR_VERMELHO;
  34.             break;
  35.         case NAIPE_OUROS:
  36.             this.naipeCor = NAIPECOR_VERMELHO;
  37.             break;
  38.         case NAIPE_PAUS:
  39.             this.naipeCor = NAIPECOR_PRETO;
  40.             break;
  41.         case NAIPE_ESPADAS:
  42.             this.naipeCor = NAIPECOR_PRETO;
  43.             break;
  44.         default:
  45.             this.naipeCor = 121212;
  46.         }
  47.         this.valor = valor;
  48.     }
  49.  
  50.     public int getValor() {
  51.         return valor;
  52.     }
  53.  
  54.     public int getNaipe() {
  55.         return naipe;
  56.     }
  57.    
  58.     public int getNaipeCor() {
  59.         return naipeCor;
  60.     }
  61.  
  62.     public boolean isParaCima() {
  63.         return paraCima;
  64.     }
  65.  
  66.     public void setParaCima(boolean paraCima) {
  67.         this.paraCima = paraCima;
  68.     }
  69.  
  70.     public String toString() {
  71.         if (this.isParaCima()) {
  72.             switch (getNaipe()) {
  73.             case NAIPE_COPAS:
  74.                 return getValor() + " de Copas";
  75.             case NAIPE_PAUS:
  76.                 return getValor() + " de Paus";
  77.             case NAIPE_OUROS:
  78.                 return getValor() + " de Ouros";
  79.             case NAIPE_ESPADAS:
  80.                 return getValor() + " de Espadas";
  81.             }
  82.  
  83.         }
  84.         return "Carta virada para baixo.";
  85.     }
  86. }
Add Comment
Please, Sign In to add comment