From f4a19118e54cb7c4a49570dff4bbdbc26bf19ddb Mon Sep 17 00:00:00 2001 From: Shavonne Cobb Date: Tue, 15 Oct 2019 13:07:03 -0500 Subject: [PATCH] added stuff! --- .idea/vcs.xml | 6 ++++ .idea/workspace.xml | 28 +++++++++++++++++- src/main/java/BattleshipBust.java | 16 +++++----- src/main/java/GameHelper.java | 8 ++--- src/main/java/SimpleBattleship.java | 2 ++ target/classes/BattleshipBust.class | Bin 3120 -> 2920 bytes target/classes/GameHelper.class | Bin 3117 -> 3098 bytes .../classes/META-INF/battleship.kotlin_module | Bin 16 -> 0 bytes target/classes/SimpleBattleship.class | Bin 1807 -> 1807 bytes 9 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 .idea/vcs.xml delete mode 100644 target/classes/META-INF/battleship.kotlin_module 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 2cdaff5f8e041bb95c0c2d6adb49a651686288cb..af2ea57353237f0af6e1eb7210374be7718e0aaa 100644 GIT binary patch delta 1493 zcma)5TT~lW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Ym$A{bF-79m^2VGu?^b|#0^Y|e@6j&F)d<74t`kD60(srkTTKd!mP=Y=R`bWV5e;D67i@+ zK4xIIi9tMW;0bZ24LoV!DFaXIct%o2MeGsrtd6}WFSIFoK|B_Zr6x1KDvLEwaxym4 zkQ?sDCUP8Ef!oK2rOQmFTi?H@Z&EtCy9IAh`gzIWPi4%Oxm4 zL5FQ$&ou#|t1`Xm7V|YKWDT$8R`F#5?Uy7k~dc& z$c>|lvVeG5C_*7BC~Jse6G}+%Qlei*^vbaYmFQ#aMq;~(5xY@~y{N+LLCTX~hgVlIM32sLZ$9Cqb?*x6TY~Q7;zKitT zVf#3){3s3ljMelhNLS!{cGtssHsKrGNz0A3ypx~WDYlMBIVHq$4i@V!Muniw69kWr zpbqcCe=l$a%YTQVqxYW%>yfVxg^*-P7ePXUGqWX!Q7!}ZRp(F>4w5Rh+4&!XIn)W< zZggihdh63d%L?X|@!nxVDg}v*+erE@&7tWKv@GgceF57pwu9JP^Kcg4J#HmCf1Y$Dk$nsO6`7rO ze?itO<{a+fgL6yee1Bp&Jr`21XZJ1}#3HDFpjgMC(p+|h_j1W+BHw+CE4gDpp2jlg zNf;%*<0ulxayqgo5c3+l5s!n^1+&`j#CgDhf8$fbF<}F#Xg_84A#(s0okfsOxg|^p wTKNmfwOlsKo$teXvV4#{A0nYP*o2fpFcJ4+nA+g6_wh@i@Nb0I;O6~*0ac7FU;qFB diff --git a/target/classes/GameHelper.class b/target/classes/GameHelper.class index 3fed5c3f8322773e505ab003dc3d1f5a040621da..9c233145cd19d3cb4810744569b0d3f08da47de6 100644 GIT binary patch delta 727 zcmXw#T};h!7{@=q&guU@=igsN9o2=ImGweS8S++yQmJ_xYOantQmT{FDJ40iyyhjp zh(z9IZrG@>OtZDQF!!#_mANo?#@0Nibo1=_efNF7&*%3%PaaCPK21+d0(m^?w+^RU z9Hhad(M6NRIs%c>Y;lZWq-(KABxKV1a&Wg&ZKK~+t;#-b(@uvXeoG(_Y6%5>%@zL8 zkw8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