50 lines
1008 B
Java
50 lines
1008 B
Java
|
|
class User {
|
|
private int id;
|
|
private static int mitgliedNummer = 1000;
|
|
private String name;
|
|
private boolean abo;
|
|
private double guthaben;
|
|
|
|
public User(String name, boolean abo, int guthaben) {
|
|
this.name = name;
|
|
this.abo = abo;
|
|
this.guthaben = guthaben;
|
|
this.id = incrementId();
|
|
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public double getGuthaben() {
|
|
return guthaben;
|
|
}
|
|
|
|
public void setGuthaben(double guthaben) {
|
|
this.guthaben = guthaben;
|
|
}
|
|
|
|
private static int incrementId() {
|
|
return mitgliedNummer++;
|
|
}
|
|
|
|
public int getId() {
|
|
return id;
|
|
}
|
|
|
|
public boolean getAbo() {
|
|
return abo;
|
|
}
|
|
|
|
public String toString() {
|
|
if (abo == true) {
|
|
return "Mitglied (" + id + "): " + name + ", Abo: Vorhanden" + ", Akteulles Guthaben: " + guthaben + "€";
|
|
} else {
|
|
return "Mitglied (" + id + "): " + name + ", Abo: nicht vorhanden" + ", Aktuelles Guthaben: " + guthaben+ "€";
|
|
}
|
|
|
|
}
|
|
}
|