Finished cleaning up the code. Ready for Demo 2

This commit is contained in:
2019-03-11 02:05:26 -06:00
parent 076ba12ef1
commit 11b16b4e40
10 changed files with 615 additions and 567 deletions

View File

@@ -18,7 +18,7 @@ public class Player {
private boolean retire = false;
private int cargoSpace = 60;
public Player(){
public Player() {
this.name = "Taipan";
this.bank = 0;
this.money = 0;
@@ -39,11 +39,11 @@ public class Player {
}
/**
* Copy constructor
*
* @param player object of the class Player
*/
public Player(Player player){
* Copy constructor
*
* @param player object of the class Player
*/
public Player(Player player) {
this.name = player.name;
this.bank = player.bank;
this.money = player.money;
@@ -63,84 +63,84 @@ public class Player {
}
/**
* getter method for the instance variable cargoSpace.
*
* @return returns the instance variable cargoSpace
*/
* getter method for the instance variable cargoSpace.
*
* @return returns the instance variable cargoSpace
*/
public int getCargoSpace() {
return cargoSpace;
}
/**
* setter method for the instance variable cargoSpace.
*
* @param cargoSpace takes an int that is greater than 0 as an argument
*/
* setter method for the instance variable cargoSpace.
*
* @param cargoSpace takes an int that is greater than 0 as an argument
*/
public void setCargoSpace(int cargoSpace) {
if(cargoSpace > 0){
if (cargoSpace > 0) {
this.cargoSpace = cargoSpace;
}
}
/**
* getter method for the instance variable retire.
*
* @return returns the instance variable retire
*/
public boolean getRetire(){
* getter method for the instance variable retire.
*
* @return returns the instance variable retire
*/
public boolean getRetire() {
return retire;
}
/**
* setter method for the instance variable retire.
*
* @param retire takes a boolean as an argument
*/
public void setRetire(boolean retire){
if(retire){
* setter method for the instance variable retire.
*
* @param retire takes a boolean as an argument
*/
public void setRetire(boolean retire) {
if (retire) {
this.retire = retire;
}
}
/**
* getter method for the instance variable name.
*
* @return returns the instance variable name
*/
* getter method for the instance variable name.
*
* @return returns the instance variable name
*/
public String getName() {
return name;
}
/**
* setter method for the instance variable name.
*
* @param name takes a string as an argument
*/
* setter method for the instance variable name.
*
* @param name takes a string as an argument
*/
public void setName(String name) {
this.name = name;
}
/**
* getter method for the instance variable HP.
*
* @return returns the instance variable HP
*/
* getter method for the instance variable HP.
*
* @return returns the instance variable HP
*/
public int getHP() {
return HP;
}
/**
* setter method for the instance variable HP.
*
* @param HP takes an int as an argument
*/
* setter method for the instance variable HP.
*
* @param HP takes an int as an argument
*/
public void setHP(int HP) {
@@ -148,21 +148,21 @@ public class Player {
}
/**
* getter method for the instance variable bank.
*
* @return returns the instance variable bank
*/
* getter method for the instance variable bank.
*
* @return returns the instance variable bank
*/
public int getBank() {
return bank;
}
/**
* setter method for the instance variable bank.
*
* @param bank takes an int that is greater than or equal to 0 as an argument
*/
* setter method for the instance variable bank.
*
* @param bank takes an int that is greater than or equal to 0 as an argument
*/
public void setBank(int bank) {
if (bank >= 0) {
this.bank = bank;
@@ -170,21 +170,21 @@ public class Player {
}
/**
* getter method for the instance variable money.
*
* @return returns the instance variable money
*/
* getter method for the instance variable money.
*
* @return returns the instance variable money
*/
public int getMoney() {
return money;
}
/**
* setter method for the instance variable money.
*
* @param money takes an int that is greater than or equal to 0 as an argument
*/
* setter method for the instance variable money.
*
* @param money takes an int that is greater than or equal to 0 as an argument
*/
public void setMoney(int money) {
if (money >= 0) {
this.money = money;
@@ -192,21 +192,21 @@ public class Player {
}
/**
* getter method for the instance variable opiumHeld.
*
* @return returns the instance variable opiumHeld
*/
* getter method for the instance variable opiumHeld.
*
* @return returns the instance variable opiumHeld
*/
public int getOpiumHeld() {
return opiumHeld;
}
/**
* setter method for the instance variable opiumHeld.
*
* @param opiumHeld takes an int that is greater than or equal to 0 as an argument
*/
* setter method for the instance variable opiumHeld.
*
* @param opiumHeld takes an int that is greater than or equal to 0 as an argument
*/
public void setOpiumHeld(int opiumHeld) {
if (opiumHeld >= 0) {
this.opiumHeld = opiumHeld;
@@ -214,42 +214,42 @@ public class Player {
}
/**
* getter method for the instance variable silkHeld.
*
* @return returns the instance variable silkHeld
*/
* getter method for the instance variable silkHeld.
*
* @return returns the instance variable silkHeld
*/
public int getSilkHeld() {
return silkHeld;
}
/**
* setter method for the instance variable silkHeld.
*
* @param silkHeld takes an int that is greater than or equal to 0 as an argument
*/
* setter method for the instance variable silkHeld.
*
* @param silkHeld takes an int that is greater than or equal to 0 as an argument
*/
public void setSilkHeld(int silkHeld) {
if (silkHeld >= 0) {
this.silkHeld = silkHeld;
}
}
/**
* getter method for the instance variable generalHeld.
*
* @return returns the instance variable generalHeld
*/
* getter method for the instance variable generalHeld.
*
* @return returns the instance variable generalHeld
*/
public int getGeneralHeld() {
return generalHeld;
}
/**
* setter method for the instance variable generalHeld.
*
* @param generalHeld takes an int that is greater than or equal to 0 as an argument
*/
* setter method for the instance variable generalHeld.
*
* @param generalHeld takes an int that is greater than or equal to 0 as an argument
*/
public void setGeneralHeld(int generalHeld) {
if (generalHeld >= 0) {
@@ -258,21 +258,21 @@ public class Player {
}
/**
* getter method for the instance variable armsHeld.
*
* @return returns the instance variable armsHeld
*/
* getter method for the instance variable armsHeld.
*
* @return returns the instance variable armsHeld
*/
public int getArmsHeld() {
return armsHeld;
}
/**
* setter method for the instance variable armsHeld.
*
* @param armsHeld takes an int that is greater than or equal to 0 as an argument
*/
* setter method for the instance variable armsHeld.
*
* @param armsHeld takes an int that is greater than or equal to 0 as an argument
*/
public void setArmsHeld(int armsHeld) {
if (armsHeld >= 0) {
this.armsHeld = armsHeld;
@@ -280,21 +280,21 @@ public class Player {
}
/**
* getter method for the instance variable location.
*
* @return returns the instance variable location
*/
* getter method for the instance variable location.
*
* @return returns the instance variable location
*/
public int getLocation() {
return location;
}
/**
* setter method for the instance variable location.
*
* @param location takes an int that is greater than or equal to 0 as an argument
*/
* setter method for the instance variable location.
*
* @param location takes an int that is greater than or equal to 0 as an argument
*/
public void setLocation(int location) {
if (location >= 0) {
this.location = location;
@@ -302,44 +302,44 @@ public class Player {
}
/**
* getter method for the instance variable guns.
*
* @return returns the instance variable guns
*/
* getter method for the instance variable guns.
*
* @return returns the instance variable guns
*/
public int getGuns() {
return guns;
}
/**
* setter method for the instance variable guns.
*
* @param guns takes an int that is greater than or equal to 0 as an argument
*/
* setter method for the instance variable guns.
*
* @param guns takes an int that is greater than or equal to 0 as an argument
*/
public void setGuns(int guns) {
if (guns >= 0) {
this.guns = guns;
}
}
/**
* getter method for the instance variable debt.
*
* @return returns the instance variable debt
*/
* getter method for the instance variable debt.
*
* @return returns the instance variable debt
*/
public int getDebt() {
return debt;
}
/**
* setter method for the instance variable debt.
*
* @param debt takes an int that is greater than or equal to 0 as an argument
*/
* setter method for the instance variable debt.
*
* @param debt takes an int that is greater than or equal to 0 as an argument
*/
public void setDebt(int debt) {
if (debt >= 0) {
this.debt = debt;
@@ -347,89 +347,89 @@ public class Player {
}
/**
* getter method for the instance variable wOpium.
*
* @return returns the instance variable wOpium
*/
* getter method for the instance variable wOpium.
*
* @return returns the instance variable wOpium
*/
public int getwOpium() {
return wOpium;
return wOpium;
}
/**
* setter method for the instance variable wOpium.
*
* @param wOpium takes an int that is greater than or equal to 0 as an argument
*/
* setter method for the instance variable wOpium.
*
* @param wOpium takes an int that is greater than or equal to 0 as an argument
*/
public void setwOpium(int wOpium) {
if (wOpium >= 0){
if (wOpium >= 0) {
this.wOpium = wOpium;
}
}
/**
* getter method for the instance variable wSilk.
*
* @return returns the instance variable wSilk
*/
* getter method for the instance variable wSilk.
*
* @return returns the instance variable wSilk
*/
public int getwSilk() {
return wSilk;
}
/**
* setter method for the instance variable wSilk.
*
* @param wSilk takes an int that is greater than or equal to 0 as an argument
*/
* setter method for the instance variable wSilk.
*
* @param wSilk takes an int that is greater than or equal to 0 as an argument
*/
public void setwSilk(int wSilk) {
if (wSilk >= 0){
if (wSilk >= 0) {
this.wSilk = wSilk;
}
}
/**
* getter method for the instance variable wGeneral.
*
* @return returns the instance variable wGeneral
*/
* getter method for the instance variable wGeneral.
*
* @return returns the instance variable wGeneral
*/
public int getwGeneral() {
return wGeneral;
}
/**
* setter method for the instance variable wGeneral.
*
* @param wGeneral takes an int that is greater than or equal to 0 as an argument
*/
* setter method for the instance variable wGeneral.
*
* @param wGeneral takes an int that is greater than or equal to 0 as an argument
*/
public void setwGeneral(int wGeneral) {
if (wGeneral >= 0){
if (wGeneral >= 0) {
this.wGeneral = wGeneral;
}
}
/**
* getter method for the instance variable wArms.
*
* @return returns the instance variable wArms
*/
* getter method for the instance variable wArms.
*
* @return returns the instance variable wArms
*/
public int getwArms() {
return wArms;
}
/**
* setter method for the instance variable wArms.
*
* @param wArms takes an int that is greater than or equal to 0 as an argument
*/
* setter method for the instance variable wArms.
*
* @param wArms takes an int that is greater than or equal to 0 as an argument
*/
public void setwArms(int wArms) {
if (wArms >= 0){
if (wArms >= 0) {
this.wArms = wArms;
}
}
@@ -437,10 +437,9 @@ public class Player {
/**
* Method to indicate that you have lost the game. If the player has lost, console will be cleared and will only
* show the statement "Game Over". After showing the message the game closes.
*
**/
public void gameOver(){
public void gameOver() {
System.out.flush();
System.out.println("Game over");
System.exit(0);