diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index be256d7..a7322cc 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,17 @@ - + + + + + + + + + + + + + + + @@ -70,4 +85,15 @@ + + + \ No newline at end of file diff --git a/src/main/java/BattleshipBust.java b/src/main/java/BattleshipBust.java index 49ebe3e..1899722 100644 --- a/src/main/java/BattleshipBust.java +++ b/src/main/java/BattleshipBust.java @@ -12,13 +12,13 @@ private void setUpGame() { ship1.setName("Lucille"); SimpleBattleship ship2 = new SimpleBattleship(); ship2.setName("Drax"); - SimpleBattleship ship3 = new SimpleBattleship(); - ship3.setName("Lilith"); +// SimpleBattleship ship3 = new SimpleBattleship(); +// ship3.setName("Lilith"); // SimpleBattleship ship4 = new SimpleBattleship(); // ship4.setName("Vincent"); battleshipList.add(ship1); battleshipList.add(ship2); - battleshipList.add(ship3); +// battleshipList.add(ship3); // battleshipList.add(ship4); System.out.println("Your goal is to sink the three Ships."); @@ -33,10 +33,10 @@ private void setUpGame() { ArrayList newLocation = helper.placeBattleship(3); ship2.setLocationCells(newLocation); } - for (SimpleBattleship lilithToSet : battleshipList) { - ArrayList newLocation = helper.placeBattleship(3); - ship3.setLocationCells(newLocation); - } +// for (SimpleBattleship lilithToSet : battleshipList) { +// ArrayList newLocation = helper.placeBattleship(3); +// ship3.setLocationCells(newLocation); +// } // for (SimpleBattleship vincentToSet : battleshipList) { // ArrayList newLocation = helper.placeBattleship(3); // ship4.setLocationCells(newLocation); @@ -60,7 +60,7 @@ private void checkUserGuess(String userGuess) { if (result.equals("hit")) { break; } - if (result.equals("kill")) { + else if (result.equals("kill")) { battleshipList.remove(x); break; } diff --git a/src/main/java/GameHelper.java b/src/main/java/GameHelper.java index af6cfcd..56b293f 100644 --- a/src/main/java/GameHelper.java +++ b/src/main/java/GameHelper.java @@ -4,9 +4,9 @@ import java.util.ArrayList; public class GameHelper { - private static final String alphabet = "abcdefg"; - private int gridLength = 7; - private int gridSize = 49; + private static final String alphabet = "abcd"; + private int gridLength = 4; + private int gridSize = 16; private int[] grid = new int[gridSize]; private int comCount = 0; @@ -39,7 +39,7 @@ public ArrayList placeBattleship(int comSize) { } while (!success & attempts++ < 200) { location = (int) (Math.random() * gridSize); - System.out.println("Try " + location); + System.out.println(location); int x = 0; success = true; while (success && x < comSize) { diff --git a/src/main/java/SimpleBattleship.java b/src/main/java/SimpleBattleship.java index 67c4c41..800296d 100644 --- a/src/main/java/SimpleBattleship.java +++ b/src/main/java/SimpleBattleship.java @@ -18,10 +18,12 @@ public String checkYourself(String userInput) { if (index >= 0) { locationCells.remove(index); result = "hit"; + return result; } if (locationCells.isEmpty()) { result = "kill"; System.out.println("Ouch! You sunk " + name + " : ( "); + } if (index <= 0) { result = "miss"; } diff --git a/target/classes/BattleshipBust.class b/target/classes/BattleshipBust.class index 2cdaff5..af2ea57 100644 Binary files a/target/classes/BattleshipBust.class and b/target/classes/BattleshipBust.class differ diff --git a/target/classes/GameHelper.class b/target/classes/GameHelper.class index 3fed5c3..9c23314 100644 Binary files a/target/classes/GameHelper.class and b/target/classes/GameHelper.class differ diff --git a/target/classes/META-INF/battleship.kotlin_module b/target/classes/META-INF/battleship.kotlin_module deleted file mode 100644 index 2983af7..0000000 Binary files a/target/classes/META-INF/battleship.kotlin_module and /dev/null differ diff --git a/target/classes/SimpleBattleship.class b/target/classes/SimpleBattleship.class index bbd56d1..0df6589 100644 Binary files a/target/classes/SimpleBattleship.class and b/target/classes/SimpleBattleship.class differ