Update Warehouse.java
This commit is contained in:
@@ -1,36 +1,54 @@
|
|||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Warehouse extends Player {
|
public class Warehouse {
|
||||||
private int wOpium = 25;
|
private int wOpium = 25;
|
||||||
private int wSilk = 0;
|
private int wSilk = 0;
|
||||||
private int wGeneral = 0;
|
private int wGeneral = 0;
|
||||||
private int wArms = 0;
|
private int wArms = 0;
|
||||||
private String good = "";
|
private String good = "";
|
||||||
private int finalAmount = 0;
|
private int finalAmount = 0;
|
||||||
|
private Player player;
|
||||||
|
|
||||||
|
|
||||||
|
public void setPlayer(Player player) {
|
||||||
|
Player playerDumy = new Player(player);
|
||||||
|
this.player= playerDumy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer(){
|
||||||
|
Player playerDummy = new Player(player);
|
||||||
|
return playerDummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Warehouse(Player player){
|
||||||
|
Player playerDummy = new Player(player);
|
||||||
|
this.player = playerDummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addAmount(String good, int amount) {
|
public void addAmount(String good, int amount) {
|
||||||
int held = 0;
|
int held = 0;
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
if (this.good.equalsIgnoreCase("O")) {
|
if (this.good.equalsIgnoreCase("O")) {
|
||||||
this.wOpium += amount;
|
this.wOpium += amount;
|
||||||
held = getOpiumHeld();
|
held = player.getOpiumHeld();
|
||||||
setOpiumHeld(held - amount);
|
player.setOpiumHeld(held - amount);
|
||||||
System.out.println(getOpiumHeld());
|
System.out.println(player.getOpiumHeld());
|
||||||
}
|
}
|
||||||
else if(this.good.equalsIgnoreCase("S")) {
|
else if(this.good.equalsIgnoreCase("S")) {
|
||||||
this.wSilk += amount;
|
this.wSilk += amount;
|
||||||
held = getSilkHeld();
|
held = player.getSilkHeld();
|
||||||
setSilkHeld(held - amount);
|
player.setSilkHeld(held - amount);
|
||||||
}
|
}
|
||||||
else if(this.good.equalsIgnoreCase("G")) {
|
else if(this.good.equalsIgnoreCase("G")) {
|
||||||
this.wGeneral += amount;
|
this.wGeneral += amount;
|
||||||
held = getGeneralHeld();
|
held = player.getGeneralHeld();
|
||||||
setGeneralHeld(held - amount);
|
player.setGeneralHeld(held - amount);
|
||||||
}
|
}
|
||||||
else if(this.good.equalsIgnoreCase("A")) {
|
else if(this.good.equalsIgnoreCase("A")) {
|
||||||
this.wArms += amount;
|
this.wArms += amount;
|
||||||
held = getArmsHeld();
|
held = player.getArmsHeld();
|
||||||
setArmsHeld(held - amount);
|
player.setArmsHeld(held - amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -42,23 +60,23 @@ public class Warehouse extends Player {
|
|||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
if (this.good.equalsIgnoreCase("O")) {
|
if (this.good.equalsIgnoreCase("O")) {
|
||||||
this.wOpium -= amount;
|
this.wOpium -= amount;
|
||||||
held = getOpiumHeld();
|
held = player.getOpiumHeld();
|
||||||
setOpiumHeld(held + amount);
|
player.setOpiumHeld(held + amount);
|
||||||
}
|
}
|
||||||
else if(this.good.equalsIgnoreCase("S")) {
|
else if(this.good.equalsIgnoreCase("S")) {
|
||||||
this.wSilk -= amount;
|
this.wSilk -= amount;
|
||||||
held = getSilkHeld();
|
held = player.getSilkHeld();
|
||||||
setSilkHeld(held + amount);
|
player.setSilkHeld(held + amount);
|
||||||
}
|
}
|
||||||
else if(this.good.equalsIgnoreCase("G")) {
|
else if(this.good.equalsIgnoreCase("G")) {
|
||||||
this.wGeneral -= amount;
|
this.wGeneral -= amount;
|
||||||
held = getGeneralHeld();
|
held = player.getGeneralHeld();
|
||||||
setGeneralHeld(held + amount);
|
player.setGeneralHeld(held + amount);
|
||||||
}
|
}
|
||||||
else if(this.good.equalsIgnoreCase("A")) {
|
else if(this.good.equalsIgnoreCase("A")) {
|
||||||
this.wArms -= amount;
|
this.wArms -= amount;
|
||||||
held = getArmsHeld();
|
held = player.getArmsHeld();
|
||||||
setArmsHeld(held + amount);
|
player.setArmsHeld(held + amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -89,16 +107,16 @@ public class Warehouse extends Player {
|
|||||||
System.out.println("Please enter the amount of the good you would like to transfer, put negative amount to remove");
|
System.out.println("Please enter the amount of the good you would like to transfer, put negative amount to remove");
|
||||||
Scanner keyboard = new Scanner(System.in);
|
Scanner keyboard = new Scanner(System.in);
|
||||||
amount = keyboard.nextInt();
|
amount = keyboard.nextInt();
|
||||||
if(this.good.equalsIgnoreCase("O") && amount <= getOpiumHeld()) {
|
if(this.good.equalsIgnoreCase("O") && amount <= player.getOpiumHeld()) {
|
||||||
finalAmount = amount;
|
finalAmount = amount;
|
||||||
}
|
}
|
||||||
else if(this.good.equalsIgnoreCase("S") && amount <= getSilkHeld()) {
|
else if(this.good.equalsIgnoreCase("S") && amount <= player.getSilkHeld()) {
|
||||||
finalAmount = amount;
|
finalAmount = amount;
|
||||||
}
|
}
|
||||||
else if(this.good.equalsIgnoreCase("G") && amount <= getGeneralHeld()) {
|
else if(this.good.equalsIgnoreCase("G") && amount <= player.getGeneralHeld()) {
|
||||||
finalAmount = amount;
|
finalAmount = amount;
|
||||||
}
|
}
|
||||||
else if(this.good.equalsIgnoreCase("A") && amount <= getArmsHeld()) {
|
else if(this.good.equalsIgnoreCase("A") && amount <= player.getArmsHeld()) {
|
||||||
finalAmount = amount;
|
finalAmount = amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user