123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import java.util.Calendar;
- import java.util.GregorianCalendar;
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author LH
- */
- public class Person
- {
- private String name,beruf,lieblingsfarbe,lieblingstier;
- private int geburtsjahr;
- private float koerpergröße;
- public Person() throws Exception
- {
- this.name = InteractiveIO.promptAndRead("Name:");
- this.beruf = InteractiveIO.promptAndRead("Beruf:");
- this.lieblingsfarbe = InteractiveIO.promptAndRead("Lieblingsfarbe:");
- this.lieblingstier = InteractiveIO.promptAndRead("Lieblingstier:");
- this.geburtsjahr=InteractiveIO.promptForInt("Geburtsjahr:");
- this.koerpergröße = InteractiveIO.promptForFloat("Körpergröße:");
- }
-
- public String toString()
- { //FICK DICH JAVA
- String alter = (((Calendar)new GregorianCalendar()).get(Calendar.YEAR)-geburtsjahr)+"";
-
-
- return "Name: "+name+"\n"+
- "Beruf: "+beruf+"\n"+
- "Lieblingsfarbe: "+lieblingsfarbe+"\n"+
- "Lieblingstier: "+lieblingstier+"n"+
- "Alter: "+alter+"n"+
- "Größe: "+koerpergröße;
-
-
-
- }
-
-
- public static void main(String[] args) throws Exception
- {
-
- Person p1=new Person(),p2=new Person();
- InteractiveIO.write(p1+"");
- InteractiveIO.write(p2+"");
- }
-
- }
|