Worked On Sid's class a bit

This commit is contained in:
KahootChampion
2019-02-24 19:56:16 -07:00
parent 0bed08ec23
commit 5f1e566c8f
4 changed files with 126 additions and 138 deletions

View File

@@ -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;