diff --git a/OGP1718-Worms/src/worms/model/Team.java b/OGP1718-Worms/src/worms/model/Team.java index 02b8f96..e82a41c 100644 --- a/OGP1718-Worms/src/worms/model/Team.java +++ b/OGP1718-Worms/src/worms/model/Team.java @@ -5,8 +5,6 @@ import java.util.Collections; import java.util.List; import worms.util.IllegalNameException; -import worms.util.ModelException; -import worms.util.MustNotImplementException; public class Team { // region constructor @@ -33,8 +31,8 @@ public class Team { public void addWormsToTeam(Worm... worm) throws IllegalArgumentException { for (Worm w: worm) { if (canHaveAsWorm(w)) { - team.add(w); - sortList(team); + wormArrayList.add(w); + sortList(wormArrayList); } else { throw new IllegalArgumentException(); @@ -53,8 +51,8 @@ public class Team { public boolean canHaveAsWorm(Worm worm) { if (worm.getMass() > getMinMassTeam()/2 && worm.getMass() < 2 * getMaxMassTeam() && !worm.isTerminated()) { - for (int i = 0; i < team.size(); i++) { - if ((team.get(i)).getName() == worm.getName()) + for (int i = 0; i < wormArrayList.size(); i++) { + if ((wormArrayList.get(i)).getName() == worm.getName()) return false; } return true; @@ -81,7 +79,7 @@ public class Team { */ public void removeWormsFromTeam(Worm... worm) { for (Worm w: worm) { - team.remove(w); + wormArrayList.remove(w); } } @@ -92,14 +90,14 @@ public class Team { * |result == team.contains(worm) */ public boolean containsWorm(Worm worm) { - if (team.contains(worm)) { + if (wormArrayList.contains(worm)) { return true; } return false; } public ArrayList getAllWormsOfTeam() { - return team; + return wormArrayList; } /** @@ -112,13 +110,13 @@ public class Team { * |supplyingTeam.isTerminated() == true */ public void mergeTeams(Team recevingTeam, Team supplyingTeam) { - for (int i = 0; i < (supplyingTeam.team).size(); i++) { - addWormsToTeam((supplyingTeam.team).get(i)); + for (int i = 0; i < (supplyingTeam.wormArrayList).size(); i++) { + addWormsToTeam((supplyingTeam.wormArrayList).get(i)); } terminate(supplyingTeam); } - private ArrayList team; + private ArrayList wormArrayList; //=================================================================================== // endregion @@ -141,9 +139,9 @@ public class Team { * | new.getMinMassTeam() == worm.getMass() */ public void setMinMassTeam() { - minMassTeam = (team.get(0)).getMass(); - for (int i = 1; i < team.size() - 1; i++) { - Worm worm = team.get(i); + minMassTeam = (wormArrayList.get(0)).getMass(); + for (int i = 1; i < wormArrayList.size() - 1; i++) { + Worm worm = wormArrayList.get(i); if (worm.getMass() < minMassTeam) { minMassTeam = worm.getMass(); } @@ -167,9 +165,9 @@ public class Team { * | new.getMaxMassTeam() == worm.getMass() */ public void setMaxMassTeam() { - maxMassTeam = (team.get(0)).getMass(); - for (int i = 1; i < team.size() - 1; i++) { - Worm worm = team.get(i); + maxMassTeam = (wormArrayList.get(0)).getMass(); + for (int i = 1; i < wormArrayList.size() - 1; i++) { + Worm worm = wormArrayList.get(i); if (worm.getMass() > maxMassTeam) { minMassTeam = worm.getMass(); } @@ -249,7 +247,7 @@ public class Team { * |new.terminate == true */ public void terminate(Team team) { - terminate = true; + this.terminated = true; } /** @@ -262,13 +260,10 @@ public class Team { * | result == false */ public boolean isTerminated(Team team) { - if (terminate == true) { - return true; - } - return false; + return this.terminated; } - private boolean terminate = false; + private boolean terminated = false; //=================================================================================== // endregion