42 lines
No EOL
703 B
Java
42 lines
No EOL
703 B
Java
public class Baustein implements Comparable<Baustein>{
|
|
|
|
// Anfang Attribute
|
|
private String zeichen;
|
|
private int anzahl;
|
|
// Ende Attribute
|
|
|
|
public Baustein(String zeichen) {
|
|
super();
|
|
anzahl = 1;
|
|
this.zeichen = zeichen;
|
|
}
|
|
// Anfang Methoden
|
|
|
|
|
|
|
|
public int compareTo(Baustein c) {
|
|
|
|
int anz = c.getAnzahl();
|
|
|
|
//ascending order
|
|
return anz - this.anzahl;
|
|
|
|
//descending order
|
|
//return compareQuantity - this.quantity;
|
|
|
|
}
|
|
public String getZeichen() {
|
|
return zeichen;
|
|
}
|
|
|
|
public int getAnzahl() {
|
|
return anzahl;
|
|
}
|
|
|
|
public void incAnzahl() {
|
|
anzahl++;
|
|
}
|
|
|
|
|
|
// Ende Methoden
|
|
} |