Update Warehouse.java

This commit is contained in:
siddhantdewani
2019-02-24 18:21:58 -07:00
committed by GitHub
parent c4e8866a8f
commit 6511f40b8b

View File

@@ -26,7 +26,7 @@ public class Warehouse {
public void addAmount() { public void addAmount() {
int amount = 0; int amount = 0;
int finalAmount; int finalAmount = 0;
System.out.println("Please enter the amount of the good you would like to ADD."); System.out.println("Please enter the amount of the good you would like to ADD.");
Scanner keyboard = new Scanner(System.in); Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextInt(); amount = keyboard.nextInt();
@@ -57,17 +57,17 @@ public class Warehouse {
else if(good.equalsIgnoreCase("S")) { else if(good.equalsIgnoreCase("S")) {
this.wSilk += finalAmount; this.wSilk += finalAmount;
held = player.getSilkHeld(); held = player.getSilkHeld();
player.setSilkHeld(held - amount); player.setSilkHeld(held - finalAmount);
} }
else if(good.equalsIgnoreCase("G")) { else if(good.equalsIgnoreCase("G")) {
this.wGeneral += finalAmount; this.wGeneral += finalAmount;
held = player.getGeneralHeld(); held = player.getGeneralHeld();
player.setGeneralHeld(held - amount); player.setGeneralHeld(held - finalAmount);
} }
else if(good.equalsIgnoreCase("A")) { else if(good.equalsIgnoreCase("A")) {
this.wArms += finalAmount; this.wArms += finalAmount;
held = player.getArmsHeld(); held = player.getArmsHeld();
player.setArmsHeld(held - amount); player.setArmsHeld(held - finalAmount);
} }
} }
else { else {
@@ -76,7 +76,7 @@ public class Warehouse {
} }
public void removeAmount() { public void removeAmount() {
int amount = 0; int amount = 0;
int finalAmount; int finalAmount = 0;
System.out.println("Please enter the amount of the good you would like to REMOVE"); System.out.println("Please enter the amount of the good you would like to REMOVE");
Scanner keyboard = new Scanner(System.in); Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextInt(); amount = keyboard.nextInt();
@@ -93,7 +93,7 @@ public class Warehouse {
finalAmount = amount; finalAmount = amount;
} }
}
String good; String good;
System.out.println("Please enter a good to transfer O, S, G, A :"); System.out.println("Please enter a good to transfer O, S, G, A :");
Scanner keyboard = new Scanner(System.in); Scanner keyboard = new Scanner(System.in);
@@ -103,29 +103,30 @@ public class Warehouse {
if (good.equalsIgnoreCase("O")) { if (good.equalsIgnoreCase("O")) {
this.wOpium -= amount; this.wOpium -= amount;
held = player.getOpiumHeld(); held = player.getOpiumHeld();
player.setOpiumHeld(held + amount); player.setOpiumHeld(held + finalAmount);
} }
else if(good.equalsIgnoreCase("S")) { else if(good.equalsIgnoreCase("S")) {
this.wSilk -= amount; this.wSilk -= amount;
held = player.getSilkHeld(); held = player.getSilkHeld();
player.setSilkHeld(held + amount); player.setSilkHeld(held + finalAmount);
} }
else if(good.equalsIgnoreCase("G")) { else if(good.equalsIgnoreCase("G")) {
this.wGeneral -= amount; this.wGeneral -= amount;
held = player.getGeneralHeld(); held = player.getGeneralHeld();
player.setGeneralHeld(held + amount); player.setGeneralHeld(held + finalAmount);
} }
else if(good.equalsIgnoreCase("A")) { else if(good.equalsIgnoreCase("A")) {
this.wArms -= amount; this.wArms -= amount;
held = player.getArmsHeld(); held = player.getArmsHeld();
player.setArmsHeld(held + amount); player.setArmsHeld(held + finalAmount);
} }
} }
else { else {
System.out.println("Sorry this transfer cannot be made"); System.out.println("Sorry this transfer cannot be made");
} }
} }
public void showWarehouse() { public void showWarehouse() {
System.out.println("Opium : " + this.wOpium); System.out.println("Opium : " + this.wOpium);
@@ -165,6 +166,7 @@ public class Warehouse {
} }
} }
} }
public static void main(String[] args){ public static void main(String[] args){
} }