Created
April 11, 2015 09:24
-
-
Save 3c7/60d6e1f7d4808ac222f6 to your computer and use it in GitHub Desktop.
Praktomat Aufgabe 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by Nils on 08.04.2015. | |
*/ | |
public class Frau extends Person { | |
public String chromosomen = "XX"; | |
public static int anzahl = 0; | |
public Frau(String n, int a, int g, int kg) { | |
super(n, a, g, kg); | |
anzahl++; | |
} | |
public int gewicht() { | |
return this.gewicht - 5; | |
} | |
public int preisHaarschnitt() { | |
return (int) Math.round(20.0 + (2.0 / 3.0) * (double) this.alter); | |
} | |
public String chromosomen() { | |
return this.chromosomen; | |
} | |
public String toString() { | |
return super.toString() + " " + this.preisHaarschnitt(); | |
} | |
public static int anzahl() { | |
return anzahl; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by Nils on 08.04.2015. | |
*/ | |
public class Mann extends Person { | |
public String chromosomen = "XY"; | |
public static int anzahl = 0; | |
public Mann(String n, int a, int g, int kg) { | |
super(n, a, g, kg); | |
anzahl++; | |
} | |
public int groesse() { | |
return this.groesse + 5; | |
} | |
public int preisHaarschnitt() { | |
return (int) Math.round(10.0 + 0.25 * (double) this.alter); | |
} | |
public String chromosomen() { | |
return this.chromosomen; | |
} | |
public String toString() { | |
return super.toString() + " " + this.preisHaarschnitt(); | |
} | |
public static int anzahl() { | |
return anzahl; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by Nils on 08.04.2015. | |
*/ | |
public abstract class Person { | |
public int alter; | |
public int gewicht; | |
public int groesse; | |
public String chromosomen; | |
public final static int volljaehrigkeit = 18; | |
public String name; | |
public static int anzahl = 0; | |
public Person(final String n, int a, int g, int kg) { | |
this.name = n; | |
this.alter = a; | |
this.groesse = g; | |
this.gewicht = kg; | |
anzahl++; | |
} | |
public String chromosomen() { | |
return this.chromosomen; | |
} | |
public String name() { | |
return this.name; | |
} | |
public int alter() { | |
return this.alter; | |
} | |
public final static int volljaehrigkeitsAlter() { | |
return volljaehrigkeit; | |
} | |
public boolean istVolljaehrig() { | |
return (this.alter >= volljaehrigkeit); | |
} | |
public int gewicht() { | |
return this.gewicht; | |
} | |
public int groesse() { | |
return this.groesse; | |
} | |
public String toString() { | |
return this.name() + " " + this.chromosomen() + " " + this.alter() + " " + this.istVolljaehrig() + " " + this.groesse() + " " + this.gewicht(); | |
} | |
public static int anzahl() { | |
return anzahl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment