added/fixed some features
This commit is contained in:
@@ -9,11 +9,11 @@ public class Raumschiff {
|
||||
private int lebenserhaltungssystemeInProzent;
|
||||
private int androidenAnzahl;
|
||||
private String schiffsname;
|
||||
private static ArrayList<String> broadcastKommunikator;
|
||||
private ArrayList<Ladung> ladungsverzeichnis;
|
||||
private static final ArrayList<String> broadcastKommunikator = new ArrayList<>();
|
||||
private final ArrayList<Ladung> ladungsverzeichnis;
|
||||
|
||||
public Raumschiff() {
|
||||
|
||||
this.ladungsverzeichnis = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Raumschiff(int photonentorpedoAnzahl, int energieversorgungInProzent, int schildeInProzent, int huelleInProzent, int lebenserhaltungssystemeInProzent, int androidenAnzahl, String schiffsname) {
|
||||
@@ -24,6 +24,7 @@ public class Raumschiff {
|
||||
this.setLebenserhaltungssystemeInProzent(lebenserhaltungssystemeInProzent);
|
||||
this.setAndroidenAnzahl(androidenAnzahl);
|
||||
this.setSchiffsname(schiffsname);
|
||||
this.ladungsverzeichnis = new ArrayList<>();
|
||||
}
|
||||
|
||||
public int getPhotonentorpedoAnzahl() {
|
||||
@@ -89,8 +90,7 @@ public class Raumschiff {
|
||||
public void photonentorpedoSchiessen(Raumschiff r) {
|
||||
if (this.getPhotonentorpedoAnzahl() == 0) {
|
||||
nachrichtAnAlle("-=*Click*=-");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.setPhotonentorpedoAnzahl(this.getPhotonentorpedoAnzahl() - 1);
|
||||
nachrichtAnAlle("Photonentorpedo abgeschossen");
|
||||
treffer(r);
|
||||
@@ -100,8 +100,7 @@ public class Raumschiff {
|
||||
public void phaserkanoneSchiessen(Raumschiff r) {
|
||||
if (this.getEnergieversorgungInProzent() < 50) {
|
||||
nachrichtAnAlle("-=*Click*=-");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.setEnergieversorgungInProzent(this.getEnergieversorgungInProzent() - 50);
|
||||
nachrichtAnAlle("Phaserkanone abgeschossen");
|
||||
treffer(r);
|
||||
@@ -109,30 +108,27 @@ public class Raumschiff {
|
||||
}
|
||||
|
||||
private void treffer(Raumschiff r) {
|
||||
System.out.println(r.getSchiffsname() + "wurde getroffen!");
|
||||
System.out.println(r.getSchiffsname() + " wurde getroffen!\n");
|
||||
|
||||
//wenn Schilde vollständig zerstört
|
||||
if (r.getSchildeInProzent() < 1) {
|
||||
|
||||
if (r.getHuelleInProzent() < 1) {
|
||||
if (r.getHuelleInProzent() < 51) {
|
||||
r.setLebenserhaltungssystemeInProzent(0);
|
||||
nachrichtAnAlle("Lebenserhaltungssysteme von Raumschiff " + r.schiffsname + " vernichtet");
|
||||
}
|
||||
else {
|
||||
//Hülle um 50 Prozent abbauen
|
||||
r.setHuelleInProzent(r.getHuelleInProzent() - 50);
|
||||
//Energieversorgung um 50 Prozent abbauen
|
||||
r.setEnergieversorgungInProzent(r.getEnergieversorgungInProzent() - 50);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//Schilde um 50 Prozent schwächen
|
||||
r.setSchildeInProzent(r.getSchildeInProzent() - 50);
|
||||
}
|
||||
}
|
||||
|
||||
public void nachrichtAnAlle(String message) {
|
||||
broadcastKommunikator.add(message);
|
||||
broadcastKommunikator.add(this.schiffsname + ": " + message);
|
||||
}
|
||||
|
||||
public ArrayList<String> eintraegeLogbuchZurueckgeben() {
|
||||
@@ -143,14 +139,15 @@ public class Raumschiff {
|
||||
if (this.ladungPhotonentorpedosAnzahl() == 0) {
|
||||
System.out.println("Keine Photonentorpedos gefunden!");
|
||||
nachrichtAnAlle("=*Click*=-");
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
//wenn Photonentorpedos mehr als in Ladung verfügbar, alle verfügbaren laden
|
||||
if (anzahlTorpedos > this.ladungPhotonentorpedosAnzahl())
|
||||
anzahlTorpedos = this.ladungPhotonentorpedosAnzahl();
|
||||
|
||||
System.out.println(anzahlTorpedos + "Photonentorpedo(s) eingesetzt");
|
||||
this.setPhotonentorpedoAnzahl(this.getPhotonentorpedoAnzahl() + anzahlTorpedos);
|
||||
ladungPhotonentorpedoVermindern(anzahlTorpedos);
|
||||
ladungsverzeichnisAufraeumen();
|
||||
System.out.println(anzahlTorpedos + " Photonentorpedo(s) eingesetzt\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,11 +158,9 @@ public class Raumschiff {
|
||||
|
||||
if (schutzschilde) {
|
||||
anzahlTrue += 1;
|
||||
}
|
||||
else if (energieversorgung) {
|
||||
} if (energieversorgung) {
|
||||
anzahlTrue += 1;
|
||||
}
|
||||
else if (schiffshuelle) {
|
||||
} if (schiffshuelle) {
|
||||
anzahlTrue += 1;
|
||||
}
|
||||
|
||||
@@ -173,11 +168,9 @@ public class Raumschiff {
|
||||
|
||||
if (schutzschilde) {
|
||||
this.setSchildeInProzent(this.getSchildeInProzent() + reparaturErg);
|
||||
}
|
||||
else if (energieversorgung) {
|
||||
} if (energieversorgung) {
|
||||
this.setEnergieversorgungInProzent(this.getEnergieversorgungInProzent() + reparaturErg);
|
||||
}
|
||||
else if (schiffshuelle) {
|
||||
} if (schiffshuelle) {
|
||||
this.setHuelleInProzent(this.getHuelleInProzent() + reparaturErg);
|
||||
}
|
||||
}
|
||||
@@ -190,6 +183,7 @@ public class Raumschiff {
|
||||
System.out.println("huelleInProzent: " + this.huelleInProzent);
|
||||
System.out.println("lebenserhaltungssystemeInProzent: " + this.lebenserhaltungssystemeInProzent);
|
||||
System.out.println("androidenAnzahl: " + this.androidenAnzahl);
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
public void ladungsverzeichnisAusgeben() {
|
||||
@@ -200,6 +194,7 @@ public class Raumschiff {
|
||||
System.out.println("Menge: " + ladung.getMenge());
|
||||
System.out.println("============================================");
|
||||
}
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
public void ladungsverzeichnisAufraeumen() {
|
||||
@@ -221,9 +216,9 @@ public class Raumschiff {
|
||||
if (ladung.getMenge() < anzahl) {
|
||||
tempToRemove = ladung.getMenge();
|
||||
anzahl -= tempToRemove;
|
||||
}
|
||||
else {
|
||||
tempToRemove = ladung.getMenge();
|
||||
} else {
|
||||
tempToRemove = anzahl;
|
||||
anzahl = 0;
|
||||
}
|
||||
ladung.setMenge(ladung.getMenge() - tempToRemove);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user