Created
September 19, 2014 08:13
-
-
Save jtuttas/75d462d5c62a4468f213 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public class Fahrzeug { | |
private double gewicht; | |
private long laufleistung; | |
public double getGewicht() { | |
return gewicht; | |
} | |
public void setGewicht(double gewicht) { | |
this.gewicht = gewicht; | |
} | |
public long getLaufleistung() { | |
return laufleistung; | |
} | |
public String toString() { | |
// TODO Auto-generated method stub | |
return "Laufleistung="+getLaufleistung()+" Gewicht="+getGewicht(); | |
} | |
} |
This file contains hidden or 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
public class ObjTraining { | |
public ObjTraining() { | |
Fahrzeug fa1 = new Fahrzeug(); | |
Fahrzeug fa2 = new Fahrzeug(); | |
fa1.setGewicht(15.0); | |
fa2.setGewicht(20.0); | |
System.out.println ("Fa1="+fa1); | |
System.out.println ("Fa2="+fa2); | |
System.out.println ("Das Durchgeschnittsgewicht beträgt:"+this.averageWeight(fa1, fa2)); | |
} | |
private double averageWeight(Fahrzeug f1,Fahrzeug f2) { | |
return (f1.getGewicht()+f2.getGewicht())/2; | |
} | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
ObjTraining o = new ObjTraining(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment