Forgot a try catch in warehouse

This commit is contained in:
KahootChampion
2019-02-24 20:38:00 -07:00
parent c59f06b127
commit 9f23ec187c
2 changed files with 82 additions and 73 deletions

48
.idea/workspace.xml generated
View File

@@ -58,8 +58,8 @@
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/Warehouse.java"> <entry file="file://$PROJECT_DIR$/src/Warehouse.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="214"> <state relative-caret-position="260">
<caret line="159" column="51" selection-start-line="159" selection-start-column="51" selection-end-line="159" selection-end-column="51" /> <caret line="154" column="82" selection-start-line="154" selection-start-column="82" selection-end-line="154" selection-end-column="82" />
</state> </state>
</provider> </provider>
</entry> </entry>
@@ -88,8 +88,8 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/loanShark.java"> <entry file="file://$PROJECT_DIR$/src/loanShark.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="600"> <state relative-caret-position="-5">
<caret line="40" column="9" selection-start-line="40" selection-start-column="9" selection-end-line="40" selection-end-column="9" /> <caret line="2" column="24" lean-forward="true" selection-start-line="2" selection-start-column="24" selection-end-line="2" selection-end-column="24" />
</state> </state>
</provider> </provider>
</entry> </entry>
@@ -105,7 +105,6 @@
</component> </component>
<component name="FindInProjectRecents"> <component name="FindInProjectRecents">
<findStrings> <findStrings>
<find>setg</find>
<find>guns</find> <find>guns</find>
<find>duplic</find> <find>duplic</find>
<find>chanceOfRun</find> <find>chanceOfRun</find>
@@ -135,6 +134,7 @@
<find>player.</find> <find>player.</find>
<find>System.out.println(&quot;\n*** PLACEHOLDER FOR LOAN SHARK ***\n&quot;);</find> <find>System.out.println(&quot;\n*** PLACEHOLDER FOR LOAN SHARK ***\n&quot;);</find>
<find>keep</find> <find>keep</find>
<find>showWa</find>
</findStrings> </findStrings>
<replaceStrings> <replaceStrings>
<replace>player.getName()</replace> <replace>player.getName()</replace>
@@ -206,7 +206,7 @@
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" /> <property name="aspect.path.notification.shown" value="true" />
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1551065365646" /> <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1551065866043" />
<property name="extract.method.default.visibility" value="public" /> <property name="extract.method.default.visibility" value="public" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" /> <property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="project.structure.last.edited" value="Project" /> <property name="project.structure.last.edited" value="Project" />
@@ -436,17 +436,24 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1551065166040</updated> <updated>1551065166040</updated>
</task> </task>
<option name="localTasksCounter" value="20" /> <task id="LOCAL-00020" summary="Small thing, changed an output of warehouse a bit, shows user its the warehosue they are concerned with.">
<created>1551065447444</created>
<option name="number" value="00020" />
<option name="presentableId" value="LOCAL-00020" />
<option name="project" value="LOCAL" />
<updated>1551065447444</updated>
</task>
<option name="localTasksCounter" value="21" />
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="45199000" /> <option name="totallyTimeSpent" value="45820000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="0" y="23" width="1280" height="709" extended-state="6" /> <frame x="0" y="23" width="1280" height="709" extended-state="6" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.3101777" /> <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.3101777" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" /> <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Image Layers" order="2" /> <window_info id="Image Layers" order="2" />
<window_info id="Designer" order="3" /> <window_info id="Designer" order="3" />
@@ -455,7 +462,7 @@
<window_info id="Favorites" order="6" side_tool="true" /> <window_info id="Favorites" order="6" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" /> <window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" /> <window_info anchor="bottom" id="Find" order="1" />
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.4989339" visible="true" weight="0.3241491" /> <window_info anchor="bottom" id="Run" order="2" sideWeight="0.4989339" weight="0.3241491" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" /> <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@@ -501,7 +508,8 @@
<MESSAGE value="linked all the classes together. The project is functional." /> <MESSAGE value="linked all the classes together. The project is functional." />
<MESSAGE value="Worked On Sid's class a bit" /> <MESSAGE value="Worked On Sid's class a bit" />
<MESSAGE value="Think I fixed Sid's code" /> <MESSAGE value="Think I fixed Sid's code" />
<option name="LAST_COMMIT_MESSAGE" value="Think I fixed Sid's code" /> <MESSAGE value="Small thing, changed an output of warehouse a bit, shows user its the warehosue they are concerned with." />
<option name="LAST_COMMIT_MESSAGE" value="Small thing, changed an output of warehouse a bit, shows user its the warehosue they are concerned with." />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/TaipanClone.iml"> <entry file="file://$PROJECT_DIR$/TaipanClone.iml">
@@ -556,13 +564,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/loanShark.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="600">
<caret line="40" column="9" selection-start-line="40" selection-start-column="9" selection-end-line="40" selection-end-column="9" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ShipWarfare.java"> <entry file="file://$PROJECT_DIR$/src/ShipWarfare.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-2290"> <state relative-caret-position="-2290">
@@ -573,10 +574,17 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/loanShark.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-5">
<caret line="2" column="24" lean-forward="true" selection-start-line="2" selection-start-column="24" selection-end-line="2" selection-end-column="24" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Warehouse.java"> <entry file="file://$PROJECT_DIR$/src/Warehouse.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="214"> <state relative-caret-position="260">
<caret line="159" column="51" selection-start-line="159" selection-start-column="51" selection-end-line="159" selection-end-column="51" /> <caret line="154" column="82" selection-start-line="154" selection-start-column="82" selection-end-line="154" selection-end-column="82" />
</state> </state>
</provider> </provider>
</entry> </entry>

View File

@@ -97,61 +97,62 @@ public class Warehouse {
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.nextLine(); amount = keyboard.nextLine();
if (Integer.parseInt(amount) <= wOpium || Integer.parseInt(amount) <=wSilk || Integer.parseInt(amount) <= wGeneral || Integer.parseInt(amount) <= wArms) { try {
finalAmount = Integer.parseInt(amount); if (Integer.parseInt(amount) <= wOpium || Integer.parseInt(amount) <= wSilk || Integer.parseInt(amount) <= wGeneral || Integer.parseInt(amount) <= wArms) {
askGood = true; finalAmount = Integer.parseInt(amount);
} else { askGood = true;
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 { } 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");
} }
} }