From 9f23ec187c87e0ee8affdbaba744e83a767088e2 Mon Sep 17 00:00:00 2001
From: KahootChampion
Date: Sun, 24 Feb 2019 20:38:00 -0700
Subject: [PATCH] Forgot a try catch in warehouse
---
.idea/workspace.xml | 48 +++++++++++---------
src/Warehouse.java | 107 ++++++++++++++++++++++----------------------
2 files changed, 82 insertions(+), 73 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 9f58b02..cb51149 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -58,8 +58,8 @@
-
-
+
+
@@ -88,8 +88,8 @@
-
-
+
+
@@ -105,7 +105,6 @@
- setg
guns
duplic
chanceOfRun
@@ -135,6 +134,7 @@
player.
System.out.println("\n*** PLACEHOLDER FOR LOAN SHARK ***\n");
keep
+ showWa
player.getName()
@@ -206,7 +206,7 @@
-
+
@@ -436,17 +436,24 @@
1551065166040
-
+
+ 1551065447444
+
+
+
+ 1551065447444
+
+
-
+
-
+
@@ -455,7 +462,7 @@
-
+
@@ -501,7 +508,8 @@
-
+
+
@@ -556,13 +564,6 @@
-
-
-
-
-
-
-
@@ -573,10 +574,17 @@
+
+
+
+
+
+
+
-
-
+
+
diff --git a/src/Warehouse.java b/src/Warehouse.java
index 5d8e324..538f418 100644
--- a/src/Warehouse.java
+++ b/src/Warehouse.java
@@ -97,61 +97,62 @@ public class Warehouse {
System.out.println("Please enter the amount of the good you would like to REMOVE");
Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextLine();
- if (Integer.parseInt(amount) <= wOpium || Integer.parseInt(amount) <=wSilk || Integer.parseInt(amount) <= wGeneral || Integer.parseInt(amount) <= wArms) {
- finalAmount = Integer.parseInt(amount);
- askGood = true;
- } else {
- System.out.println("Nice try but you don't have any items of that quantity in the warehouse!");
- askGood = false;
- }
-
- if (askGood == true) {
- String good;
- System.out.println("Please enter a good to transfer O, S, G, A :");
- good = keyboard.nextLine();
- int held = 0;
- if (Integer.parseInt(amount) > 0) {
- if (good.equalsIgnoreCase("O")) {
- if (this.wOpium >= Integer.parseInt(amount)) {
- this.wOpium -= Integer.parseInt(amount);
- held = player.getOpiumHeld();
- player.setOpiumHeld(held + finalAmount);
- } else {
- System.out.println("You don't have that much opium stored in the warehouse!");
- }
- } else if (good.equalsIgnoreCase("S")) {
- if (this.wSilk >= Integer.parseInt(amount)) {
- this.wSilk -= Integer.parseInt(amount);
- held = player.getSilkHeld();
- player.setSilkHeld(held + finalAmount);
- }
- else{
- System.out.println("You don't have that much silk stored in the warehouse!");
- }
- } else if (good.equalsIgnoreCase("G")) {
- if (this.wGeneral >= Integer.parseInt(amount)) {
- this.wGeneral -= Integer.parseInt(amount);
- held = player.getGeneralHeld();
- player.setGeneralHeld(held + finalAmount);
- }
- else{
- System.out.println("You don't have that much general cargo stored in the warehouse!");
-
- }
- } else if (good.equalsIgnoreCase("A")) {
- if (this.wArms >= Integer.parseInt(amount)) {
- this.wArms -= Integer.parseInt(amount);
- held = player.getArmsHeld();
- player.setArmsHeld(held + finalAmount);
- }
- else{
- System.out.println("You don't have that much arms stored in the warehouse!");
-
- }
- }
+ try {
+ if (Integer.parseInt(amount) <= wOpium || Integer.parseInt(amount) <= wSilk || Integer.parseInt(amount) <= wGeneral || Integer.parseInt(amount) <= wArms) {
+ finalAmount = Integer.parseInt(amount);
+ askGood = true;
} else {
- System.out.println("Sorry this transfer cannot be made");
+ System.out.println("Nice try but you don't have any items of that quantity in the warehouse!");
+ askGood = false;
}
+
+ if (askGood == true) {
+ String good;
+ System.out.println("Please enter a good to transfer O, S, G, A :");
+ good = keyboard.nextLine();
+ int held = 0;
+ if (Integer.parseInt(amount) > 0) {
+ if (good.equalsIgnoreCase("O")) {
+ if (this.wOpium >= Integer.parseInt(amount)) {
+ this.wOpium -= Integer.parseInt(amount);
+ held = player.getOpiumHeld();
+ player.setOpiumHeld(held + finalAmount);
+ } else {
+ System.out.println("You don't have that much opium stored in the warehouse!");
+ }
+ } else if (good.equalsIgnoreCase("S")) {
+ if (this.wSilk >= Integer.parseInt(amount)) {
+ this.wSilk -= Integer.parseInt(amount);
+ held = player.getSilkHeld();
+ player.setSilkHeld(held + finalAmount);
+ } else {
+ System.out.println("You don't have that much silk stored in the warehouse!");
+ }
+ } else if (good.equalsIgnoreCase("G")) {
+ if (this.wGeneral >= Integer.parseInt(amount)) {
+ this.wGeneral -= Integer.parseInt(amount);
+ held = player.getGeneralHeld();
+ player.setGeneralHeld(held + finalAmount);
+ } else {
+ System.out.println("You don't have that much general cargo stored in the warehouse!");
+
+ }
+ } else if (good.equalsIgnoreCase("A")) {
+ if (this.wArms >= Integer.parseInt(amount)) {
+ this.wArms -= Integer.parseInt(amount);
+ held = player.getArmsHeld();
+ player.setArmsHeld(held + finalAmount);
+ } else {
+ System.out.println("You don't have that much arms stored in the warehouse!");
+
+ }
+ }
+ } else {
+ System.out.println("Sorry this transfer cannot be made");
+ }
+ }
+ }catch (Exception e){
+ System.out.println("Wait, that's not a valid input please try again");
}
}