run_n_inf7/Quellcodes/iud_key_inf7_breakmono/Baustein.java
2025-01-02 12:26:47 +01:00

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
}