Hallo. Kann mir jemand sagen wie das in Code ausschauen würde? Ist mein Beispiel unten richtig?
Dankeschön!
Dankeschön!

Code:
public class Auto {
private HashSet<Motor> motoren;
public Auto(int anzahlMotoren) {
motoren = new HashSet<Motor>();
for(int i = 0; i <= anzahlMotoren; i++) {
motoren.add(new Motor());
}
}
public void setMotoren(HashSet<Motor> motoren) {
this.motoren = motoren;
}
public HashSet<Motor> getMotoren() {
return motoren;
}
}
Code:
public class Motor {
}