Skip to content

Commit

Permalink
added stuff!
Browse files Browse the repository at this point in the history
  • Loading branch information
Shavonne Cobb authored and Shavonne Cobb committed Oct 15, 2019
1 parent db52c39 commit f4a1911
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 13 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 27 additions & 1 deletion .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions src/main/java/BattleshipBust.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand All @@ -33,10 +33,10 @@ private void setUpGame() {
ArrayList<String> newLocation = helper.placeBattleship(3);
ship2.setLocationCells(newLocation);
}
for (SimpleBattleship lilithToSet : battleshipList) {
ArrayList<String> newLocation = helper.placeBattleship(3);
ship3.setLocationCells(newLocation);
}
// for (SimpleBattleship lilithToSet : battleshipList) {
// ArrayList<String> newLocation = helper.placeBattleship(3);
// ship3.setLocationCells(newLocation);
// }
// for (SimpleBattleship vincentToSet : battleshipList) {
// ArrayList<String> newLocation = helper.placeBattleship(3);
// ship4.setLocationCells(newLocation);
Expand All @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/GameHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -39,7 +39,7 @@ public ArrayList<String> 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) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/SimpleBattleship.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
Binary file modified target/classes/BattleshipBust.class
Binary file not shown.
Binary file modified target/classes/GameHelper.class
Binary file not shown.
Binary file removed target/classes/META-INF/battleship.kotlin_module
Binary file not shown.
Binary file modified target/classes/SimpleBattleship.class
Binary file not shown.

0 comments on commit f4a1911

Please sign in to comment.