Skip to content

Instantly share code, notes, and snippets.

@jtuttas
Created September 19, 2014 08:13
Show Gist options
  • Save jtuttas/75d462d5c62a4468f213 to your computer and use it in GitHub Desktop.
Save jtuttas/75d462d5c62a4468f213 to your computer and use it in GitHub Desktop.
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();
}
}
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