Advertisement
Alfoli

Jogo - classe carta

Mar 13th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. public class Carta {
  2.     private String imagem;
  3.     private char naipe;
  4.     private int numero;
  5.     private boolean aberta;
  6.    
  7.     public Carta() {
  8.         this.imagem = " ";
  9.         this.naipe = 'o';
  10.         this.numero = 0;
  11.         this.aberta = false;
  12.     }
  13.    
  14.     public Carta(String i, char n, int num, boolean a) {
  15.         this.imagem = i;
  16.         this.naipe = n;
  17.         this.numero = num;
  18.         this.aberta = a;
  19.     }
  20.    
  21.     public String toString() {
  22.         String saida = "\n";
  23.         switch (this.naipe) {
  24.             case 'o':{
  25.                 saida+="Ouros";
  26.                 break;
  27.             }
  28.             case 'e':{
  29.                 saida+="Espadas";
  30.                 break;
  31.             }
  32.             case 'c':{
  33.                 saida+="Copas";
  34.                 break;
  35.             }
  36.             case 'p':{
  37.                 saida+="Paus";
  38.                 break;
  39.             }
  40.         }
  41.         switch(this.numero) {
  42.             case 1:{
  43.                 saida += "As";
  44.                 break;
  45.             }
  46.             case 11:{
  47.                 saida += "J";
  48.                 break;
  49.             }
  50.             case 12:{
  51.                 saida += "D";
  52.                 break;
  53.             }
  54.             case 13:{
  55.                 saida += "K";
  56.                 break;
  57.             }
  58.             default:{
  59.                 saida += "Numero:" + String.format("%d", this.numero);
  60.                 break;
  61.             }
  62.         }
  63.         return saida;
  64.     }
  65.    
  66.     public String getImagem(){
  67.         return this.imagem;
  68.     }
  69.    
  70.     public void setImagem (String i) {
  71.         this.imagem = i;
  72.     }
  73.    
  74.     public char getNaipe() {
  75.         return this.naipe;
  76.     }
  77.    
  78.     public void setNaipe(char n) {
  79.         this.naipe = n;
  80.     }
  81.    
  82.     public int getNumero() {
  83.         return this.numero;
  84.     }
  85.    
  86.     public void setNumero(int num) {
  87.         this.numero = num;
  88.     }
  89.    
  90.     public boolean getAberta() {
  91.         return this.aberta;
  92.     }
  93.    
  94.     public void setAberta(boolean a) {
  95.         this.aberta = a;
  96.     }
  97.  
  98.    
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement