Commit f3b4f80c authored by Darth Vernon's avatar Darth Vernon

Battle class comments

parent 96685993
......@@ -5,34 +5,36 @@ public class BattleClass {
public Boolean fire ( ShipClass opponent, String Coordinates) {
public Boolean fire ( ShipClass opponent, String Coordinates) { //Takes shipClass object of fired upon player, and the coordinates of that fire.
Boolean hit = false;
if(opponent.allMoves.contains(Coordinates)) {
//Fire successful
opponent.allMoves.remove(Coordinates);
opponent.allMoves.remove(Coordinates); //Ship destroyed, thus removed.
hit = true;
}
return hit;
return hit; //Returns true if hit.
}
public static String ShipCheck(String coordinates, ShipClass opponent) {
public static String ShipCheck(String coordinates, ShipClass opponent) { //Takes shipClass object of fired upon player, and the coordinates of that fire.
String response = "Hit ";
//Only called if hit (from fire) is true, so it is assumed one of the opponent's ship list contains the entered.
if (opponent.aC.contains(coordinates)) {
opponent.aC.remove(coordinates);
opponent.aC.remove(coordinates); //Coordinates are removed, as part of ship is destroyed.
if (opponent.aC.isEmpty()) {
response = ("sunk Aircarft one");
response = ("sunk Aircarft one"); //Ship list is empty and can therefore be reported as sunk.
}
}
......@@ -98,7 +100,7 @@ public class BattleClass {
response = ("sunk Patrol boat three");
}
}
return response;
return response; //Defaults to hit if nothing is sunk.
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment