| home | suche | kontakt/johner | institut | hinweise studierende | tech-docs | blog | mindmailer |
![]() |
Fahrzeug
package fuhrpark;
import java.io.Serializable;
public class Fahrzeug implements Serializable{
private String typ;
private int ps;
public Fahrzeug(){}
public Fahrzeug(String typ, int ps) {
this.typ = typ;
this.ps = ps;
}
public String getTyp() {
return typ;
}
public void setTyp(String typ) {
this.typ = typ;
}
public int getPs() {
return ps;
}
public void setPs(int ps) {
this.ps = ps;
}
}
Fuhrpark
package fuhrpark;
import java.util.HashSet;
import java.util.Set;
public class Fuhrpark {
private Set<Fahrzeug> fahrzeuge = new HashSet<Fahrzeug>();
public Fuhrpark(){
fahrzeuge.add(new Fahrzeug("Audi", 91));
}
public int add(int a, int b){
return a + b;
}
public Fahrzeug getErstesFahrzeug(){
for(Fahrzeug fahrzeug: fahrzeuge){
return fahrzeug;
}
return null;
}
public void addFahrzeug(Fahrzeug fahrzeug){
fahrzeuge.add(fahrzeug);
}
public int getAnzahlFahrzeuge(){
return fahrzeuge.size();
}
}
