diff --git a/.idea/misc.xml b/.idea/misc.xml
index 479cb83..8466a13 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c708ac9..ea1a992 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,7 +1,13 @@
-
+
+
+
+
+
+
+
@@ -28,8 +34,8 @@
-
-
+
+
@@ -37,8 +43,8 @@
-
-
+
+
@@ -46,11 +52,11 @@
-
-
+
+
-
-
+
+
@@ -59,8 +65,8 @@
-
-
+
+
@@ -68,8 +74,18 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -77,17 +93,29 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
@@ -98,7 +126,7 @@
-
+
@@ -115,7 +143,6 @@
- eek
setg
guns
duplic
@@ -145,6 +172,7 @@
set
player.
System.out.println("\n*** PLACEHOLDER FOR LOAN SHARK ***\n");
+ cargoSpace
player.getName()
@@ -169,14 +197,14 @@
@@ -192,8 +220,6 @@
-
-
@@ -210,6 +236,8 @@
+
+
@@ -438,7 +466,14 @@
1551060234136
-
+
+ 1551105597993
+
+
+
+ 1551105597993
+
+
@@ -448,7 +483,7 @@
-
+
@@ -501,7 +536,8 @@
-
+
+
@@ -511,52 +547,20 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
@@ -565,22 +569,67 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/out/production/TaipanClone/ShipWarfare.class b/out/production/TaipanClone/ShipWarfare.class
deleted file mode 100644
index 73760e7..0000000
Binary files a/out/production/TaipanClone/ShipWarfare.class and /dev/null differ
diff --git a/src/Player.java b/src/Player.java
index ee0c02b..8aa5f73 100644
--- a/src/Player.java
+++ b/src/Player.java
@@ -16,6 +16,7 @@ public class Player {
private int wGeneral = 0;
private int wArms = 0;
private boolean retire = false;
+ private int cargoSpace = 60;
public Player(){
@@ -39,6 +40,24 @@ public class Player {
}
+ /**
+ * getter method for the instance variable cargoSpace.
+ * @return cargoSpace
+ */
+ public int getCargoSpace() {
+ return cargoSpace;
+ }
+
+ /**
+ * setter method for cargoSpace.
+ * @param cargoSpace
+ */
+ public void setCargoSpace(int cargoSpace) {
+ if(cargoSpace > 0){
+ this.cargoSpace = cargoSpace;
+ }
+ }
+
public boolean getRetire(){
return retire;
}
diff --git a/src/TaipanShop.java b/src/TaipanShop.java
index 633f946..002f68c 100644
--- a/src/TaipanShop.java
+++ b/src/TaipanShop.java
@@ -3,107 +3,161 @@ import java.util.Scanner;
public class TaipanShop {
private Player player;
- private int cargoSpace = 60;
- private int currentCargo = 0;
private int opiumPrice = 16000;
private int silkPrice = 1600;
private int armsPrice = 160;
private int generalPrice = 8;
+ /**
+ * This method is evoked if the user is eligible to win, and chooses to end the game (by winning).
+ */
public void retire(){
player.setRetire(true);
System.out.println("You win!");
+ System.exit(0);
}
+ /**
+ * sets the player instance variable equal to a copy of the parameter -- a copy is used for encapsulation purposes.
+ *
+ * @param player is a Player object that will replace the current instance of the player instance variable.
+ */
public void setPlayer(Player player) {
Player playerDummy = new Player(player);
this.player = playerDummy;
}
+ /**
+ * gets the player instance variable. The method returns a copy of the instance variable for encapsulation purposes.
+ *
+ * @return playerDummy -- playerDummy is a copy of the player instance variable.
+ */
public Player getPlayer(){
Player playerDummy = new Player(player);
return playerDummy;
}
+ /**
+ * constructor; only runs when a Player object is provided. The constructor is fully encapsulated.
+ *
+ * @param player is a Player object that will be copied and the player instance variable is set to the copy.
+ */
public TaipanShop(Player player){
Player playerDummy = new Player(player);
this.player = playerDummy;
}
- public int getCargoSpace() {
- return cargoSpace;
- }
-
- public void setCargoSpace(int cargoSpace) {
- if(cargoSpace > 0){
- this.cargoSpace = cargoSpace;
- }
- }
-
+ /**
+ *
+ * @return
+ */
public int getOpiumPrice() {
return opiumPrice;
}
+ /**
+ *
+ * @param opiumPrice
+ */
public void setOpiumPrice(int opiumPrice) {
if(opiumPrice > 0){
this.opiumPrice = opiumPrice;
}
}
+ /**
+ *
+ * @return
+ */
public int getSilkPrice() {
return silkPrice;
}
+ /**
+ *
+ * @param silkPrice
+ */
public void setSilkPrice(int silkPrice) {
if(silkPrice > 0){
this.silkPrice = silkPrice;
}
}
+ /**
+ *
+ * @return
+ */
public int getArmsPrice() {
return armsPrice;
}
+ /**
+ *
+ * @param armsPrice
+ */
public void setArmsPrice(int armsPrice) {
if(armsPrice > 0){
this.armsPrice = armsPrice;
}
}
+ /**
+ *
+ * @return
+ */
public int getGeneralPrice() {
return generalPrice;
}
+ /**
+ *
+ * @param generalPrice
+ */
public void setGeneralPrice(int generalPrice) {
if(generalPrice > 0){
this.generalPrice = generalPrice;
}
}
+ /**
+ *
+ */
public void travel(){
Travel travel = new Travel(player);
travel.travelTo();
player = travel.getPlayer();
}
+ /**
+ *
+ */
public void warehouse(){
Warehouse warehouse = new Warehouse(player);
warehouse.changeWarehouse();
player = warehouse.getPlayer();
}
+ /**
+ *
+ */
public void bank(){
Bank bank = new Bank(player);
bank.bank();
player = bank.getPlayer();
}
+ /**
+ *
+ */
public void loan(){
loanShark loan = new loanShark(player);
loan.loanMoney();
player = loan.getPlayer();
}
-
+
+ /**
+ *
+ */
private void updatePrices(){
String s = "\n" + player.getName() + ", the price of ";
double value = 80*Math.random();
@@ -149,12 +203,15 @@ public class TaipanShop {
}
}
+ /**
+ *
+ */
private void printShop(){
- currentCargo = player.getOpiumHeld()+player.getGuns()*10+player.getSilkHeld()+player.getArmsHeld()+player.getGeneralHeld();
- if(cargoSpace - currentCargo < 0){
+ int currentCargo = player.getOpiumHeld()+player.getGuns()*10+player.getSilkHeld()+player.getArmsHeld()+player.getGeneralHeld();
+ if(player.getCargoSpace() - currentCargo < 0){
System.out.println("Hold: Overloaded" + " Guns: " + player.getGuns() + " HP: " + player.getHP() +"%");
}else{
- System.out.println("Hold: " + (cargoSpace-currentCargo) + " Guns: " + player.getGuns() + " HP: " + player.getHP() +"%");
+ System.out.println("Hold: " + (player.getCargoSpace()-currentCargo) + " Guns: " + player.getGuns() + " HP: " + player.getHP() +"%");
}
System.out.println("-------------------------------------------------------------");
System.out.println(" Opium: " + player.getOpiumHeld() + " Silk: " + player.getSilkHeld());
@@ -166,6 +223,11 @@ public class TaipanShop {
System.out.println(" Arms: " + armsPrice + " General: " + generalPrice);
}
+ /**
+ *
+ * @param notDone
+ * @param input
+ */
public void atLocationOne(boolean notDone, Scanner input){
while(notDone){
printShop();
@@ -314,6 +376,11 @@ public class TaipanShop {
}
}
+ /**
+ *
+ * @param notDone
+ * @param input
+ */
public void notAtLocationOne(boolean notDone, Scanner input){
while(notDone){
printShop();
@@ -454,6 +521,11 @@ public class TaipanShop {
}
}
+ /**
+ *
+ * @param notDone
+ * @param input
+ */
public void retireAndLocationOne(boolean notDone, Scanner input){
while(notDone){
printShop();
@@ -604,6 +676,9 @@ public class TaipanShop {
}
}
+ /**
+ *
+ */
public void shop() {
updatePrices();
Scanner input = new Scanner(System.in);