Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.time.LocalDate;
- import java.time.Period;
- public class Person{
- public String Nachname;
- protected String Vorname;
- protected String Strasse;
- protected String Ort;
- protected int Plz;
- protected String Date;
- // standard Konstruktor
- public Person(){
- System.out.println("Konstruktor");
- }
- // überladener Konstruktor
- public Person(String nachname, String vorname){
- this.Nachname = nachname;
- this.Vorname = vorname;
- System.out.println("anderer Konstruktor");
- } // Konstruktor Adresse
- public Person(String nachname, String vorname, String geburtsdatum ,String strasse, String ort, int plz){
- this.Strasse = strasse;
- this.Ort = ort;
- this.Plz = plz;
- this.Nachname = nachname;
- this.Vorname = vorname;
- this.Date = geburtsdatum;
- }
- @Override
- public String toString(){
- return this.getNachnameVorname();
- }
- //Adresse
- //set
- public void setStrasse(String strasse){
- this.Strasse = strasse;
- }
- public void setOrt(String ort){
- this.Ort = ort;
- }
- public void setPlz(int plz){
- this.Plz = plz;
- }
- // get
- public String getStrasse(){
- return this.Strasse;
- }
- public String getOrt(){
- return this.Ort;
- }
- public int getPlz(){
- return this.Plz;
- }
- //Adresse
- public String getAdresse(){
- return this.Strasse + " " + this.Ort + " " + this.Plz;
- }
- // nachname vorname
- //set
- public void setNachname(String nachname){
- this.Nachname = nachname;
- }
- public void setVorname(String vorname){
- this.Vorname = vorname;
- }
- //get
- public String getNachname(){
- return this.Nachname;
- }
- public String getVorname(){
- return this.Vorname;
- }
- // concat Nachname und Vorname
- public String getNachnameVorname(){
- return this.Nachname + " " + this.Vorname;
- }
- public int getAlter(){
- LocalDate birthday = LocalDate.parse(this.Date);
- LocalDate currentDate = LocalDate.now();
- return Period.between(birthday, currentDate).getYears();
- }
- public void setAlter(String date){
- this.Date = date;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement