Added Javadoc comments
This commit is contained in:
232
src/Player.java
232
src/Player.java
@@ -24,6 +24,11 @@ public class Player {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
*
|
||||
* @param player object of the class Player
|
||||
*/
|
||||
public Player(Player player){
|
||||
this.bank = player.bank;
|
||||
this.money = player.money;
|
||||
@@ -39,146 +44,307 @@ public class Player {
|
||||
this.wSilk = player.wSilk;
|
||||
this.wGeneral = player.wGeneral;
|
||||
this.wArms = player.wArms;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for the instance variable cargoSpace.
|
||||
* @return cargoSpace
|
||||
*
|
||||
* @return returns the instance variable cargoSpace
|
||||
*/
|
||||
|
||||
public int getCargoSpace() {
|
||||
return cargoSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for cargoSpace.
|
||||
* @param cargoSpace
|
||||
* 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){
|
||||
this.cargoSpace = cargoSpace;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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){
|
||||
this.retire = retire;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
public void setHP(int HP) {
|
||||
|
||||
this.HP = HP;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
public void setBank(int bank) {
|
||||
if (bank >= 0) {
|
||||
this.bank = bank;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
public void setMoney(int money) {
|
||||
if (money >= 0) {
|
||||
this.money = money;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
public void setOpiumHeld(int opiumHeld) {
|
||||
if (opiumHeld >= 0) {
|
||||
this.opiumHeld = opiumHeld;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
public void setSilkHeld(int silkHeld) {
|
||||
if (silkHeld >= 0) {
|
||||
this.silkHeld = silkHeld;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
public void setGeneralHeld(int generalHeld) {
|
||||
if (generalHeld >= 0) {
|
||||
this.generalHeld = generalHeld;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
public void setArmsHeld(int armsHeld) {
|
||||
if (armsHeld >= 0) {
|
||||
this.armsHeld = armsHeld;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
public void setLocation(int location) {
|
||||
if (location >= 0) {
|
||||
this.location = location;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
public void setGuns(int guns) {
|
||||
if (guns >= 0) {
|
||||
this.guns = guns;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
public void setDebt(int debt) {
|
||||
if (debt >= 0) {
|
||||
this.debt = debt;
|
||||
}
|
||||
}
|
||||
|
||||
public int getwOpium(){ return wOpium; }
|
||||
/**
|
||||
* getter method for the instance variable wOpium.
|
||||
*
|
||||
* @return returns the instance variable wOpium
|
||||
*/
|
||||
|
||||
public int getwOpium() {
|
||||
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
|
||||
*/
|
||||
|
||||
public void setwOpium(int wOpium) {
|
||||
if (wOpium >= 0){
|
||||
@@ -186,7 +352,21 @@ public class Player {
|
||||
}
|
||||
}
|
||||
|
||||
public int getwSilk(){return 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
|
||||
*/
|
||||
|
||||
public void setwSilk(int wSilk) {
|
||||
if (wSilk >= 0){
|
||||
@@ -194,7 +374,21 @@ public class Player {
|
||||
}
|
||||
}
|
||||
|
||||
public int getwGeneral(){return 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
|
||||
*/
|
||||
|
||||
public void setwGeneral(int wGeneral) {
|
||||
if (wGeneral >= 0){
|
||||
@@ -202,7 +396,21 @@ public class Player {
|
||||
}
|
||||
}
|
||||
|
||||
public int getwArms(){return 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
|
||||
*/
|
||||
|
||||
public void setwArms(int wArms) {
|
||||
if (wArms >= 0){
|
||||
@@ -210,10 +418,14 @@ public class Player {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to indicate that you have lost the game
|
||||
*
|
||||
*/
|
||||
|
||||
public void gameOver(){
|
||||
System.out.flush();
|
||||
System.out.println("Game over");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user