diff --git a/.idea/misc.xml b/.idea/misc.xml index 8466a13..479cb83 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,7 @@ - + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f662041..d6f0198 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,12 @@ - + + + + + + @@ -192,8 +185,8 @@ - + @@ -215,7 +208,7 @@ - + @@ -435,12 +428,12 @@ - - + - + @@ -449,7 +442,7 @@ - + @@ -458,8 +451,8 @@ - - + + @@ -503,16 +496,6 @@ - - - - - - - - - - @@ -525,47 +508,29 @@ - - - - - - - - - - - - - - - - + + - - - - - - + + - - + + - - + + @@ -576,6 +541,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ShipWarfare.java b/src/ShipWarfare.java index e63f64f..fc29444 100644 --- a/src/ShipWarfare.java +++ b/src/ShipWarfare.java @@ -7,7 +7,7 @@ import java.util.concurrent.TimeUnit; Learned how to use the Time Unit Class from the following source: Slim, and Lalith Verma. “How to Use TimeUnit in Java.” Stack Overflow, 8 Dec. 2017, stackoverflow.com/questions/47717633/how-to-use-timeunit-in-java. - */ +*/ public class ShipWarfare extends Player { diff --git a/src/Warehouse.java b/src/Warehouse.java index 41c4270..7ed5feb 100644 --- a/src/Warehouse.java +++ b/src/Warehouse.java @@ -1,7 +1,7 @@ import java.util.Scanner; public class Warehouse { - private int wOpium = 25; + private int wOpium = 0; private int wSilk = 0; private int wGeneral = 0; private int wArms = 0; @@ -25,71 +25,69 @@ public class Warehouse { public void addAmount() { - int amount = 0; + boolean askGood = false; + String amount; int finalAmount = 0; System.out.println("Please enter the amount of the good you would like to ADD."); Scanner keyboard = new Scanner(System.in); - amount = keyboard.nextInt(); - if(amount <= player.getOpiumHeld()) { - finalAmount = amount; + amount = keyboard.nextLine(); + try { + if (Integer.parseInt(amount) <= player.getOpiumHeld() || Integer.parseInt(amount) <= player.getSilkHeld() ||Integer.parseInt(amount) <= player.getGeneralHeld() || Integer.parseInt(amount) <= player.getArmsHeld()) { + finalAmount = Integer.parseInt(amount); + askGood=true; + } else { + System.out.println("Nice try but you don't have any items of that quantity!"); + askGood=false; } - else if(amount <= player.getSilkHeld()) { - finalAmount = amount; + 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")) { + this.wOpium += finalAmount; + held = player.getOpiumHeld(); + player.setOpiumHeld(held - finalAmount); + System.out.println(player.getOpiumHeld()); + } else if (good.equalsIgnoreCase("S")) { + this.wSilk += finalAmount; + held = player.getSilkHeld(); + player.setSilkHeld(held - finalAmount); + } else if (good.equalsIgnoreCase("G")) { + this.wGeneral += finalAmount; + held = player.getGeneralHeld(); + player.setGeneralHeld(held - finalAmount); + } else if (good.equalsIgnoreCase("A")) { + this.wArms += finalAmount; + held = player.getArmsHeld(); + player.setArmsHeld(held - finalAmount); + } + } else { + System.out.println("Sorry this transfer cannot be made"); + } } - else if(amount <= player.getGeneralHeld()) { - finalAmount = amount; - } - else if(amount <= player.getArmsHeld()) { - finalAmount = amount; - } - String good; - System.out.println("Please enter a good to transfer O, S, G, A :"); - good = keyboard.nextLine(); - int held = 0; - if (amount > 0) { - if (good.equalsIgnoreCase("O")) { - this.wOpium += finalAmount; - held = player.getOpiumHeld(); - player.setOpiumHeld(held - finalAmount); - System.out.println(player.getOpiumHeld()); - } - else if(good.equalsIgnoreCase("S")) { - this.wSilk += finalAmount; - held = player.getSilkHeld(); - player.setSilkHeld(held - finalAmount); - } - else if(good.equalsIgnoreCase("G")) { - this.wGeneral += finalAmount; - held = player.getGeneralHeld(); - player.setGeneralHeld(held - finalAmount); - } - else if(good.equalsIgnoreCase("A")) { - this.wArms += finalAmount; - held = player.getArmsHeld(); - player.setArmsHeld(held - finalAmount); - } - } - 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"); } } public void removeAmount() { - int amount = 0; + String amount; int finalAmount = 0; System.out.println("Please enter the amount of the good you would like to REMOVE"); Scanner keyboard = new Scanner(System.in); - amount = keyboard.nextInt(); - if(amount <= this.wOpium) { - finalAmount = amount; + amount = keyboard.nextLine(); + if(Integer.parseInt(amount) <= this.wOpium) { + finalAmount = Integer.parseInt(amount); } - else if(amount <= this.wSilk) { - finalAmount = amount; + else if(Integer.parseInt(amount) <= this.wSilk) { + finalAmount = Integer.parseInt(amount); } - else if(amount <= this.wGeneral) { - finalAmount = amount; + else if(Integer.parseInt(amount) <= this.wGeneral) { + finalAmount = Integer.parseInt(amount); } - else if(amount <= this.wArms) { - finalAmount = amount; + else if(Integer.parseInt(amount) <= this.wArms) { + finalAmount = Integer.parseInt(amount); } @@ -97,24 +95,24 @@ public class Warehouse { System.out.println("Please enter a good to transfer O, S, G, A :"); good = keyboard.nextLine(); int held = 0; - if (amount > 0) { + if (Integer.parseInt(amount) > 0) { if (good.equalsIgnoreCase("O")) { - this.wOpium -= amount; + this.wOpium -= Integer.parseInt(amount); held = player.getOpiumHeld(); player.setOpiumHeld(held + finalAmount); } else if(good.equalsIgnoreCase("S")) { - this.wSilk -= amount; + this.wSilk -= Integer.parseInt(amount); held = player.getSilkHeld(); player.setSilkHeld(held + finalAmount); } else if(good.equalsIgnoreCase("G")) { - this.wGeneral -= amount; + this.wGeneral -= Integer.parseInt(amount); held = player.getGeneralHeld(); player.setGeneralHeld(held + finalAmount); } else if(good.equalsIgnoreCase("A")) { - this.wArms -= amount; + this.wArms -= Integer.parseInt(amount); held = player.getArmsHeld(); player.setArmsHeld(held + finalAmount); } @@ -154,6 +152,7 @@ public class Warehouse { String check; System.out.println("Would you like to do any other business? Y / N?"); check = keyboard.nextLine(); + check=keyboard.nextLine(); if(check.equalsIgnoreCase("Y")) { keepGoing = true;