Carta.java 1.28 KB
Newer Older
Oscar committed
1
public class Carta {
Emanuel Lugo committed
2

3 4
    public String valor;
    public String palo;
Emanuel Lugo committed
5

6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
    public Carta() {

    }

    public Carta(String completo) {
        if (completo.charAt(0) == 'A')
            this.valor = "1";
        else if (completo.charAt(0) == 'T')
            this.valor = "10";
        else if (completo.charAt(0) == 'J')
            this.valor = "11";
        else if (completo.charAt(0) == 'Q')
            this.valor = "12";
        else if (completo.charAt(0) == 'K')
            this.valor = "13";
        else
            this.valor = String.valueOf(completo.charAt(0));

        this.palo = String.valueOf(completo.charAt(1));
Oscar committed
25
    }
26

27 28 29 30 31 32 33 34 35 36 37 38 39
    String valorPalo() {
        if (this.valor.equals("1")) {
            return "A" + this.palo;
        } else if (this.valor.equals("10")) {
            return "T" + this.palo;
        } else if (this.valor.equals("11")) {
            return "J" + this.palo;
        } else if (this.valor.equals("12")) {
            return "Q" + this.palo;
        } else if (this.valor.equals("13")) {
            return "K" + this.palo;
        } else
            return this.valor + this.palo;
40

41 42 43
    }

    public int getValorInt() {
44 45
        int aux = Integer.parseInt(this.valor);
        return aux;
46

47
    }
48

49 50
    public String getPalo() {
        return this.palo;
51

52 53
    }

Oscar committed
54
}