Small thing, changed an output of warehouse a bit, shows user its the warehouse they are concerned with.
This commit is contained in:
@@ -11,6 +11,10 @@ public class Player {
|
|||||||
private int guns = 0;
|
private int guns = 0;
|
||||||
private int HP = 100;
|
private int HP = 100;
|
||||||
private int debt = 0;
|
private int debt = 0;
|
||||||
|
private int wOpium = 0;
|
||||||
|
private int wSilk = 0;
|
||||||
|
private int wGeneral = 0;
|
||||||
|
private int wArms = 0;
|
||||||
private boolean retire = false;
|
private boolean retire = false;
|
||||||
|
|
||||||
public Player(){
|
public Player(){
|
||||||
@@ -28,6 +32,11 @@ public class Player {
|
|||||||
this.guns = player.guns;
|
this.guns = player.guns;
|
||||||
this.HP = player.HP;
|
this.HP = player.HP;
|
||||||
this.debt = player.debt;
|
this.debt = player.debt;
|
||||||
|
this.wOpium = player.wOpium;
|
||||||
|
this.wSilk = player.wSilk;
|
||||||
|
this.wGeneral = player.wGeneral;
|
||||||
|
this.wArms = player.wArms;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getRetire(){
|
public boolean getRetire(){
|
||||||
@@ -148,6 +157,38 @@ public class Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getwOpium(){ return wOpium; }
|
||||||
|
|
||||||
|
public void setwOpium(int wOpium) {
|
||||||
|
if (wOpium >= 0){
|
||||||
|
this.wOpium = wOpium;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getwSilk(){return wSilk;}
|
||||||
|
|
||||||
|
public void setwSilk(int wSilk) {
|
||||||
|
if (wSilk >= 0){
|
||||||
|
this.wSilk = wSilk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getwGeneral(){return wGeneral;}
|
||||||
|
|
||||||
|
public void setwGeneral(int wGeneral) {
|
||||||
|
if (wGeneral >= 0){
|
||||||
|
this.wGeneral = wGeneral;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getwArms(){return wArms;}
|
||||||
|
|
||||||
|
public void setwArms(int wArms) {
|
||||||
|
if (wArms >= 0){
|
||||||
|
this.wArms = wArms;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void gameOver(){
|
public void gameOver(){
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
System.out.println("Game over");
|
System.out.println("Game over");
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Warehouse {
|
public class Warehouse {
|
||||||
private int wOpium = 0;
|
/*private int wOpium = 0;
|
||||||
private int wSilk = 0;
|
private int wSilk = 0;
|
||||||
private int wGeneral = 0;
|
private int wGeneral = 0;
|
||||||
private int wArms = 0;
|
private int wArms = 0;*/
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ public class Warehouse {
|
|||||||
if (Integer.parseInt(amount) > 0) {
|
if (Integer.parseInt(amount) > 0) {
|
||||||
if (good.equalsIgnoreCase("O")) {
|
if (good.equalsIgnoreCase("O")) {
|
||||||
if (player.getOpiumHeld() >= Integer.parseInt(amount)) {
|
if (player.getOpiumHeld() >= Integer.parseInt(amount)) {
|
||||||
this.wOpium += finalAmount;
|
player.setwOpium(player.getwOpium() + finalAmount);
|
||||||
held = player.getOpiumHeld();
|
held = player.getOpiumHeld();
|
||||||
player.setOpiumHeld(held - finalAmount);
|
player.setOpiumHeld(held - finalAmount);
|
||||||
System.out.println(player.getOpiumHeld());
|
System.out.println(player.getOpiumHeld());
|
||||||
@@ -56,7 +56,7 @@ public class Warehouse {
|
|||||||
}
|
}
|
||||||
} else if (good.equalsIgnoreCase("S")) {
|
} else if (good.equalsIgnoreCase("S")) {
|
||||||
if (player.getSilkHeld() >= Integer.parseInt(amount)) {
|
if (player.getSilkHeld() >= Integer.parseInt(amount)) {
|
||||||
this.wSilk += finalAmount;
|
player.setwSilk(player.getwSilk() + finalAmount);
|
||||||
held = player.getSilkHeld();
|
held = player.getSilkHeld();
|
||||||
player.setSilkHeld(held - finalAmount);
|
player.setSilkHeld(held - finalAmount);
|
||||||
} else {
|
} else {
|
||||||
@@ -65,7 +65,7 @@ public class Warehouse {
|
|||||||
}
|
}
|
||||||
} else if (good.equalsIgnoreCase("G")) {
|
} else if (good.equalsIgnoreCase("G")) {
|
||||||
if (player.getGeneralHeld() >= Integer.parseInt(amount)) {
|
if (player.getGeneralHeld() >= Integer.parseInt(amount)) {
|
||||||
this.wGeneral += finalAmount;
|
player.setwGeneral(player.getwGeneral() + finalAmount);
|
||||||
held = player.getGeneralHeld();
|
held = player.getGeneralHeld();
|
||||||
player.setGeneralHeld(held - finalAmount);
|
player.setGeneralHeld(held - finalAmount);
|
||||||
} else {
|
} else {
|
||||||
@@ -74,7 +74,7 @@ public class Warehouse {
|
|||||||
}
|
}
|
||||||
} else if (good.equalsIgnoreCase("A")) {
|
} else if (good.equalsIgnoreCase("A")) {
|
||||||
if (player.getArmsHeld() >= Integer.parseInt(amount)) {
|
if (player.getArmsHeld() >= Integer.parseInt(amount)) {
|
||||||
this.wArms += finalAmount;
|
player.setwArms(player.getwArms() + finalAmount);
|
||||||
held = player.getArmsHeld();
|
held = player.getArmsHeld();
|
||||||
player.setArmsHeld(held - finalAmount);
|
player.setArmsHeld(held - finalAmount);
|
||||||
} else {
|
} else {
|
||||||
@@ -98,7 +98,7 @@ public class Warehouse {
|
|||||||
Scanner keyboard = new Scanner(System.in);
|
Scanner keyboard = new Scanner(System.in);
|
||||||
amount = keyboard.nextLine();
|
amount = keyboard.nextLine();
|
||||||
try {
|
try {
|
||||||
if (Integer.parseInt(amount) <= wOpium || Integer.parseInt(amount) <= wSilk || Integer.parseInt(amount) <= wGeneral || Integer.parseInt(amount) <= wArms) {
|
if (Integer.parseInt(amount) <= player.getwOpium() || Integer.parseInt(amount) <= player.getwSilk() || Integer.parseInt(amount) <= player.getwGeneral() || Integer.parseInt(amount) <= player.getwArms()) {
|
||||||
finalAmount = Integer.parseInt(amount);
|
finalAmount = Integer.parseInt(amount);
|
||||||
askGood = true;
|
askGood = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -113,24 +113,24 @@ public class Warehouse {
|
|||||||
int held = 0;
|
int held = 0;
|
||||||
if (Integer.parseInt(amount) > 0) {
|
if (Integer.parseInt(amount) > 0) {
|
||||||
if (good.equalsIgnoreCase("O")) {
|
if (good.equalsIgnoreCase("O")) {
|
||||||
if (this.wOpium >= Integer.parseInt(amount)) {
|
if (player.getwOpium() >= Integer.parseInt(amount)) {
|
||||||
this.wOpium -= Integer.parseInt(amount);
|
player.setwOpium(player.getwOpium() - Integer.parseInt(amount));
|
||||||
held = player.getOpiumHeld();
|
held = player.getOpiumHeld();
|
||||||
player.setOpiumHeld(held + finalAmount);
|
player.setOpiumHeld(held + finalAmount);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("You don't have that much opium stored in the warehouse!");
|
System.out.println("You don't have that much opium stored in the warehouse!");
|
||||||
}
|
}
|
||||||
} else if (good.equalsIgnoreCase("S")) {
|
} else if (good.equalsIgnoreCase("S")) {
|
||||||
if (this.wSilk >= Integer.parseInt(amount)) {
|
if (player.getwSilk() >= Integer.parseInt(amount)) {
|
||||||
this.wSilk -= Integer.parseInt(amount);
|
player.setwSilk(player.getwSilk() - Integer.parseInt(amount));
|
||||||
held = player.getSilkHeld();
|
held = player.getSilkHeld();
|
||||||
player.setSilkHeld(held + finalAmount);
|
player.setSilkHeld(held + finalAmount);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("You don't have that much silk stored in the warehouse!");
|
System.out.println("You don't have that much silk stored in the warehouse!");
|
||||||
}
|
}
|
||||||
} else if (good.equalsIgnoreCase("G")) {
|
} else if (good.equalsIgnoreCase("G")) {
|
||||||
if (this.wGeneral >= Integer.parseInt(amount)) {
|
if (player.getwGeneral() >= Integer.parseInt(amount)) {
|
||||||
this.wGeneral -= Integer.parseInt(amount);
|
player.setwGeneral(player.getwGeneral() - Integer.parseInt(amount));
|
||||||
held = player.getGeneralHeld();
|
held = player.getGeneralHeld();
|
||||||
player.setGeneralHeld(held + finalAmount);
|
player.setGeneralHeld(held + finalAmount);
|
||||||
} else {
|
} else {
|
||||||
@@ -138,8 +138,8 @@ public class Warehouse {
|
|||||||
|
|
||||||
}
|
}
|
||||||
} else if (good.equalsIgnoreCase("A")) {
|
} else if (good.equalsIgnoreCase("A")) {
|
||||||
if (this.wArms >= Integer.parseInt(amount)) {
|
if (player.getwArms() >= Integer.parseInt(amount)) {
|
||||||
this.wArms -= Integer.parseInt(amount);
|
player.setwArms(player.getwArms() - Integer.parseInt(amount));
|
||||||
held = player.getArmsHeld();
|
held = player.getArmsHeld();
|
||||||
player.setArmsHeld(held + finalAmount);
|
player.setArmsHeld(held + finalAmount);
|
||||||
} else {
|
} else {
|
||||||
@@ -159,10 +159,10 @@ public class Warehouse {
|
|||||||
|
|
||||||
public void showWarehouse() {
|
public void showWarehouse() {
|
||||||
System.out.println("--------------------\nWarehouse\n--------------------");
|
System.out.println("--------------------\nWarehouse\n--------------------");
|
||||||
System.out.println("Opium : " + this.wOpium);
|
System.out.println("Opium : " + player.getwOpium());
|
||||||
System.out.println("Silk : " + this.wSilk);
|
System.out.println("Silk : " + player.getwSilk());
|
||||||
System.out.println("General : " + this.wGeneral);
|
System.out.println("General : " + player.getwGeneral());
|
||||||
System.out.println("Arms : " + this.wArms);
|
System.out.println("Arms : " + player.getwArms());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user