Created
November 14, 2014 10:57
-
-
Save jtuttas/bccfb3341773cbaf9a82 to your computer and use it in GitHub Desktop.
Aufgabe 7
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
package dq.fiae12e; | |
public class ObjTraining { | |
private Produkt fuhrpark[] = new Produkt[10]; | |
public ObjTraining() { | |
Fahrrad f1 = new Fahrrad(12, 0); | |
f1.setHersteller("Gudereit"); | |
f1.setPreis(600); | |
Fahrrad f2 = new Fahrrad(13.5, 0); | |
f2.setHersteller("Kettler"); | |
f2.setPreis(250); | |
Kfz kfz1 = new Kfz(800); | |
kfz1.setHersteller("Opel"); | |
kfz1.setPreis(15000); | |
Kfz kfz2 = new Kfz(950); | |
kfz2.setHersteller("Ford"); | |
kfz2.setPreis(6900); | |
Kfz kfz3 = new Kfz(1010); | |
kfz2.setHersteller("BMW"); | |
kfz2.setPreis(22000); | |
fuhrpark[0] = kfz1; | |
fuhrpark[1] = kfz2; | |
fuhrpark[2] = kfz3; | |
fuhrpark[3] = f1; | |
fuhrpark[4] = f2; | |
double gesammtGewicht = calcGesamtGewicht(); | |
double gesamtPreis = calcGesamtPreis(); | |
System.out.println("Das Gesamtgewicht beträgt " + gesammtGewicht | |
+ " der gesammtPreis beträgt " + gesamtPreis); | |
kfz1.drive(12000); | |
kfz2.drive(22000); | |
kfz2.drive(43000); | |
gesammtGewicht = calcGesamtGewicht(); | |
gesamtPreis = calcGesamtPreis(); | |
System.out.println("Das Gesamtgewicht beträgt " + gesammtGewicht | |
+ " der gesammtPreis beträgt " + gesamtPreis); | |
/* | |
Dachgepaecktraeger da1 = new Dachgepaecktraeger(); | |
kfz1.apply(da1); | |
da1.applyFahrrad1(f1); | |
da1.applyFahrrad2(f2); | |
Skibox sk1 = new Skibox(); | |
kfz2.apply(sk1); | |
System.out.println("Mit Dachgepäcktrager kfz1=" + kfz1); | |
System.out.println("Mit Skibox kfz2=" + kfz2); | |
System.out.println("Ich besitze insgesammt " | |
+ Produkt.getNumberOfProducts() + " Produkte"); | |
*/ | |
} | |
private double calcGesamtGewicht() { | |
double g=0; | |
for (Produkt p : fuhrpark) { | |
if (p != null) { | |
g += p.getGewicht(); | |
} | |
} | |
return g; | |
} | |
private double calcGesamtPreis() { | |
double g=0; | |
for (Produkt p : fuhrpark) { | |
if (p != null) { | |
g += p.getPreis(); | |
} | |
} | |
return g; | |
} | |
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