Guest User

Untitled

a guest
Apr 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.89 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.             break;
  47.         }
  48.         this.valor = valor;
  49.     }
  50.  
  51.     public int getValor() {
  52.         return valor;
  53.     }
  54.  
  55.     public int getNaipe() {
  56.         return naipe;
  57.     }
  58.    
  59.     public int getNaipeCor() {
  60.         return naipeCor;
  61.     }
  62.  
  63.     public boolean isParaCima() {
  64.         return paraCima;
  65.     }
  66.  
  67.     public void setParaCima(boolean paraCima) {
  68.         this.paraCima = paraCima;
  69.     }
  70.  
  71.     public String toString() {
  72.         if (this.isParaCima()) {
  73.             switch (getNaipe()) {
  74.             case NAIPE_COPAS:
  75.                 return getValor() + " de Copas";
  76.             case NAIPE_PAUS:
  77.                 return getValor() + " de Paus";
  78.             case NAIPE_OUROS:
  79.                 return getValor() + " de Ouros";
  80.             case NAIPE_ESPADAS:
  81.                 return getValor() + " de Espadas";
  82.             }
  83.  
  84.         }
  85.         return "Carta virada para baixo.";
  86.     }
  87. }
Add Comment
Please, Sign In to add comment