
Untitled
By: a guest on Jan 28th, 2012 | syntax:
Java | size: 0.86 KB | hits: 19 | expires: Never
public class Karte {
public final static int KARO = 0, HERZ = 1, PIK = 2, KREUZ = 3;
private final int farbe, wert;
private final String typ;
public Karte(int f, int w, String a){
farbe = f;
wert = w;
typ = a;
}
public int getWert(){
return wert;
};
public int getFarbe(){
return farbe;
};
public String getTyp(){
return typ;
};
public String toString(){
if (getTyp().startsWith("Z")) return farbe2String() + " " + wert + " " + typ2String();
else return farbe2String() + " " + typ2String();
}
public String farbe2String(){
switch(farbe){
case KARO:
return "Karo";
case HERZ:
return "Herz";
case PIK:
return "Pik";
case KREUZ:
return "Kreuz";
}
return "-1";
}
public String typ2String(){
if (getTyp().startsWith("Z")) return "";
else return getTyp();
}
}