2024-11-08 16:21:34 +01:00
|
|
|
|
|
|
|
import java.util.Date;
|
2024-11-13 17:48:43 +01:00
|
|
|
import java.util.Calendar;
|
2024-11-08 16:21:34 +01:00
|
|
|
|
2024-11-13 17:48:43 +01:00
|
|
|
class Benutzer {
|
2024-11-08 16:21:34 +01:00
|
|
|
private String name;
|
|
|
|
private String nachname;
|
|
|
|
private int kundennummer;
|
|
|
|
private Date date;
|
|
|
|
|
2024-11-13 17:48:43 +01:00
|
|
|
|
|
|
|
// Konstruktor
|
|
|
|
Benutzer(String name, String nachname, int kundennummer, Date date) {
|
|
|
|
this.name = name;
|
|
|
|
this.nachname = nachname;
|
|
|
|
this.date = date;
|
|
|
|
this.kundennummer = kundennummer;
|
2024-11-08 16:21:34 +01:00
|
|
|
}
|
|
|
|
|
2024-11-13 17:48:43 +01:00
|
|
|
// Getter-Methoden
|
2024-11-08 16:21:34 +01:00
|
|
|
public String getNachname() {
|
|
|
|
return nachname;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2024-11-13 17:48:43 +01:00
|
|
|
public Date getDate() {
|
2024-11-08 16:21:34 +01:00
|
|
|
return date;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getKundennummer() {
|
|
|
|
return kundennummer;
|
|
|
|
}
|
|
|
|
|
2024-11-13 17:48:43 +01:00
|
|
|
// Methode zum Extrahieren des Jahres aus dem Date
|
|
|
|
public static int getJahr(Benutzer benutzer) {
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
calendar.setTime(benutzer.getDate()); // Setzt das Date in das Calendar-Objekt
|
|
|
|
return calendar.get(Calendar.YEAR); // Gibt das Jahr aus dem Calendar-Objekt zurück
|
|
|
|
}
|
2024-11-08 16:21:34 +01:00
|
|
|
|
|
|
|
|
2024-11-13 17:48:43 +01:00
|
|
|
// Die Unterklassen Erwachsen und Kinder bleiben unverändert
|
|
|
|
public static class Erwachsen extends Benutzer {
|
|
|
|
Erwachsen(String name, String nachname, int kundennummer, Date date) {
|
|
|
|
super(name, nachname, kundennummer, date);
|
|
|
|
}
|
2024-11-08 16:21:34 +01:00
|
|
|
}
|
|
|
|
|
2024-11-13 17:48:43 +01:00
|
|
|
public static class Kinder extends Benutzer {
|
|
|
|
Kinder(String name, String nachname, int kundennummer, Date date) {
|
|
|
|
super(name, nachname, kundennummer, date);
|
2024-11-08 16:21:34 +01:00
|
|
|
}
|
2024-11-13 17:48:43 +01:00
|
|
|
}
|
|
|
|
public static class Admin extends Benutzer {
|
|
|
|
Admin(String name, String nachname, int kundennummer, Date date) {
|
|
|
|
super(name, nachname, kundennummer, date);
|
2024-11-08 16:21:34 +01:00
|
|
|
|
2024-11-13 17:48:43 +01:00
|
|
|
}
|
2024-11-08 16:21:34 +01:00
|
|
|
}
|
2024-11-13 17:48:43 +01:00
|
|
|
|
2024-11-08 16:21:34 +01:00
|
|
|
}
|
2024-11-13 17:48:43 +01:00
|
|
|
|