From 83057e863f0008822617a14f766e73bd4df74c87 Mon Sep 17 00:00:00 2001 From: Vikram Date: Mon, 25 Feb 2019 07:39:57 -0700 Subject: [PATCH] the comment somehow made it so that I couldn't compile (using the command line i couldn't compile, i could compile file using intellij) Also, you the file extended player, which is not necessary. You also were calling gameOver() and getName() directly, you needed "player." before all those methods. --- .idea/workspace.xml | 94 ++++++++++++++++++++++++-------------------- src/ShipWarfare.java | 21 ++++------ 2 files changed, 58 insertions(+), 57 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f662041..c708ac9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -29,7 +29,7 @@ - + @@ -37,7 +37,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -77,8 +77,8 @@ - - + + @@ -86,7 +86,7 @@ - + @@ -98,7 +98,7 @@ - + @@ -192,8 +192,8 @@ - + @@ -431,7 +431,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -555,24 +539,48 @@ - + - - + + + + + + + + + + + + + + + + + + + - + + + + + + + + - + diff --git a/src/ShipWarfare.java b/src/ShipWarfare.java index e63f64f..49efdca 100644 --- a/src/ShipWarfare.java +++ b/src/ShipWarfare.java @@ -2,14 +2,7 @@ import java.util.Scanner; import java.util.Random; import java.util.concurrent.TimeUnit; -/* - -Learned how to use the Time Unit Class from the following source: -Slim, and Lalith Verma. “How to Use TimeUnit in Java.” Stack Overflow, 8 Dec. 2017, stackoverflow.com/questions/47717633/how-to-use-timeunit-in-java. - - */ - -public class ShipWarfare extends Player { +public class ShipWarfare { private int numOfPeasantShips = 0; private int numOfLittyShips = 0; @@ -192,7 +185,7 @@ public class ShipWarfare extends Player { System.out.println("Got eem"); delayForASecond(); } else if (hitOrMiss == 2) { - System.out.printf("ARRG! We missed %s\n", getName()); + System.out.printf("ARRG! We missed %s\n", player.getName()); delayForASecond(); } else { System.out.println("Darn! Their fleet tanked our attack"); @@ -218,7 +211,7 @@ public class ShipWarfare extends Player { setNumOfLittyShips(numOfLittyShips - howMuchRun); if (userAttacks == true) { - System.out.printf("Cowards! %d ships ran away %s!\n", howMuchRun, getName()); + System.out.printf("Cowards! %d ships ran away %s!\n", howMuchRun, player.getName()); } else { System.out.printf("Escaped %d of them!\n", howMuchRun); } @@ -269,7 +262,7 @@ public class ShipWarfare extends Player { System.out.printf("We got $%,d!\n", calculateLoot); return true; } else if (exitValue == 2) { - gameOver(); + player.gameOver(); return true; } else if (exitValue == 3) { System.out.printf("We made it out at %d%% ship status!\n", player.getHP()); @@ -304,7 +297,7 @@ public class ShipWarfare extends Player { System.out.println("Got eem"); delayForASecond(); } else { - System.out.printf("ARRG! We missed %s\n", getName()); + System.out.printf("ARRG! We missed %s\n", player.getName()); delayForASecond(); } @@ -327,7 +320,7 @@ public class ShipWarfare extends Player { setNumOfPeasantShips(numOfPeasantShips - howMuchRun); if (userAttacks == true) { - System.out.printf("Ahhh, %d ships ran away %s!\n", howMuchRun, getName()); + System.out.printf("Ahhh, %d ships ran away %s!\n", howMuchRun, player.getName()); } else { System.out.printf("Escaped %d of them!\n", howMuchRun); } @@ -378,7 +371,7 @@ public class ShipWarfare extends Player { System.out.printf("We got $%,d!", calculateLoot); return true; } else if (exitValue == 2) { - gameOver(); + player.gameOver(); return true; } else if (exitValue == 3) { System.out.printf("We made it out at %d%% ship status!\n", player.getHP());