This commit is contained in:
2022-12-14 11:50:24 +01:00
parent 10b05a1a9e
commit e623a802e4
12 changed files with 176 additions and 2 deletions

View File

@@ -1,2 +1,95 @@
package EidP_BP_3;public class Boot {
package EidP_BP_3;
public class Boot {
String BootsName;
int BootsId, AnzahlPassagiere, AnzahlPersonal, AnzahlMeilen;
public String getBootsName() {
return BootsName;
}
public void setBootsName(String bootsName) {
BootsName = bootsName;
}
public int getBootsId() {
return BootsId;
}
public void setBootsId(int bootsId) {
BootsId = bootsId;
}
public int getAnzahlPassagiere() {
return AnzahlPassagiere;
}
public void setAnzahlPassagiere(int anzahlPassagiere) {
AnzahlPassagiere = anzahlPassagiere;
}
public int getAnzahlPersonal() {
return AnzahlPersonal;
}
public void setAnzahlPersonal(int anzahlPersonal) {
AnzahlPersonal = anzahlPersonal;
}
public int getAnzahlMeilen() {
return AnzahlMeilen;
}
public void setAnzahlMeilen(int anzahlMeilen) {
AnzahlMeilen = anzahlMeilen;
}
public double getTreibstoff() {
return Treibstoff;
}
public void setTreibstoff(double treibstoff) {
Treibstoff = treibstoff;
}
public double getVerbrauchProMeile() {
return VerbrauchProMeile;
}
public void setVerbrauchProMeile(double verbrauchProMeile) {
VerbrauchProMeile = verbrauchProMeile;
}
double Treibstoff, VerbrauchProMeile;
boolean fahreMeilen(int Meilen){
if(VerbrauchProMeile * Meilen <= Treibstoff){
AnzahlMeilen -= Meilen;
Treibstoff -= VerbrauchProMeile * Meilen;
return true;
}
return false;
}
boolean fuegePersonHinzu(boolean istPassagier){
if( istPassagier && AnzahlPersonal*10<= AnzahlPassagiere + 1){
AnzahlPassagiere++;
return true;
} else if ((!istPassagier) &&( AnzahlPersonal +1 <= AnzahlPassagiere)) {
AnzahlPersonal++;
return true;
}
return false;
}
public Boot(String pBootsName, double pTreibstoff, double pVerbrauchProMeile, int pAnzahlMeilen, int pAnzahlPersonal, int pAnzahlPassagiere){
BootsName = pBootsName;
BootsId = this.hashCode();
AnzahlPersonal = pAnzahlPersonal;
AnzahlPassagiere = pAnzahlPassagiere;
Treibstoff = pTreibstoff;
VerbrauchProMeile = pVerbrauchProMeile;
AnzahlMeilen = pAnzahlMeilen;
}
}

View File

@@ -1,2 +1,32 @@
package EidP_BP_3;public class BootsTest {
package EidP_BP_3;
public class BootsTest {
public static void main(String[] args) {
Boot helgoland = new Boot("helgoland", 5000, 100,2000, 50,500);
Boot sylt = new Boot("sylt",500,10,2500,7,50);
Boot ronsby = new Boot("ronsby", 5000, 10,2500,22,100);
System.out.println(helgoland.fahreMeilen(2000));
System.out.println(sylt.fahreMeilen(2500));
System.out.println(ronsby.fahreMeilen(2500));
helgoland.setAnzahlPassagiere(helgoland.getAnzahlPassagiere()+200);
helgoland.setAnzahlPersonal(helgoland.getAnzahlPersonal()+50);
sylt.setAnzahlPassagiere(sylt.getAnzahlPassagiere()+200);
sylt.setAnzahlPersonal(sylt.getAnzahlPersonal()+50);
ronsby.setAnzahlPassagiere(ronsby.getAnzahlPassagiere()+200);
ronsby.setAnzahlPersonal(ronsby.getAnzahlPersonal()+50);
System.out.println(helgoland.getBootsName()+ " " + helgoland.getAnzahlPassagiere() + " " + helgoland.getAnzahlPersonal() +" "+helgoland.getTreibstoff() );
System.out.println(sylt.getBootsName()+ " " + sylt.getAnzahlPassagiere() + " " + sylt.getAnzahlPersonal() +" "+sylt.getTreibstoff() );
System.out.println(ronsby.getBootsName()+ " " + ronsby.getAnzahlPassagiere() + " " + ronsby.getAnzahlPersonal() +" "+ronsby.getTreibstoff() );
}
}