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