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/README.md b/README.md
new file mode 100644
index 0000000..893c2b0
--- /dev/null
+++ b/README.md
@@ -0,0 +1,8 @@
+# TaipanClone
+Computer Science 233 project, Winter 2019
+
+To run the program, please go to src>start.java and run that program.
+For input, the program usually takes the first letter of whichever option you need to select. Example:
+What would you like to buy? Valid inputs are "O" (for Opium), "S" (for Silk), "A" (for Arms), "G" (for General cargo).
+
+You lose if your HP reaches 0. You can win if you "retire" in Hong Kong while having a net worth of over $1 million.
diff --git a/out/production/TaipanClone/ShipWarfare.class b/out/production/TaipanClone/ShipWarfare.class
index 967eead..73760e7 100644
Binary files a/out/production/TaipanClone/ShipWarfare.class and b/out/production/TaipanClone/ShipWarfare.class differ
diff --git a/src/Bank.java b/src/Bank.java
index 6d3ca6a..b76f423 100644
--- a/src/Bank.java
+++ b/src/Bank.java
@@ -29,6 +29,7 @@ public class Bank{
if(response.equalsIgnoreCase("W")){
boolean notDone2 = true;
while(notDone2){
+ System.out.println("How much do you wish to Withdraw?");
int withdraw = input.nextInt();
if(withdraw <= player.getBank()){
player.setMoney(withdraw + player.getMoney());
@@ -40,6 +41,7 @@ public class Bank{
}else if(response.equalsIgnoreCase("D")){
boolean notDone2 = true;
while(notDone2){
+ System.out.println("How much do you wish to Deposit?");
int deposit = input.nextInt();
if(deposit <= player.getMoney()){
player.setBank(deposit + player.getBank());
@@ -54,6 +56,7 @@ public class Bank{
while(notDone3){
System.out.println("Would you like to continue? Y/N");
response = input.nextLine();
+ response = input.nextLine();
if(response.equalsIgnoreCase("Y")){
notDone3 = false;
}else if(response.equalsIgnoreCase("N")){
diff --git a/src/Player.java b/src/Player.java
index d1deca3..ee0c02b 100644
--- a/src/Player.java
+++ b/src/Player.java
@@ -11,6 +11,10 @@ public class Player {
private int guns = 0;
private int HP = 100;
private int debt = 0;
+ private int wOpium = 0;
+ private int wSilk = 0;
+ private int wGeneral = 0;
+ private int wArms = 0;
private boolean retire = false;
public Player(){
@@ -28,6 +32,11 @@ public class Player {
this.guns = player.guns;
this.HP = player.HP;
this.debt = player.debt;
+ this.wOpium = player.wOpium;
+ this.wSilk = player.wSilk;
+ this.wGeneral = player.wGeneral;
+ this.wArms = player.wArms;
+
}
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(){
System.out.flush();
System.out.println("Game over");
diff --git a/src/Warehouse.java b/src/Warehouse.java
index 41c4270..016ad5d 100644
--- a/src/Warehouse.java
+++ b/src/Warehouse.java
@@ -1,170 +1,205 @@
import java.util.Scanner;
public class Warehouse {
- private int wOpium = 25;
- private int wSilk = 0;
- private int wGeneral = 0;
- private int wArms = 0;
- private Player player;
-
-
- public void setPlayer(Player player) {
- Player playerDumy = new Player(player);
- this.player= playerDumy;
- }
-
- public Player getPlayer(){
- Player playerDummy = new Player(player);
- return playerDummy;
- }
-
- public Warehouse(Player player){
- Player playerDummy = new Player(player);
- this.player = playerDummy;
- }
-
-
- public void addAmount() {
- int amount = 0;
- 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;
- }
- else if(amount <= player.getSilkHeld()) {
- finalAmount = amount;
- }
- 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");
- }
- }
- public void removeAmount() {
- int amount = 0;
- 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;
- }
- else if(amount <= this.wSilk) {
- finalAmount = amount;
- }
- else if(amount <= this.wGeneral) {
- finalAmount = amount;
- }
- else if(amount <= this.wArms) {
- 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 -= amount;
- held = player.getOpiumHeld();
- player.setOpiumHeld(held + finalAmount);
- }
- else if(good.equalsIgnoreCase("S")) {
- this.wSilk -= amount;
- held = player.getSilkHeld();
- player.setSilkHeld(held + finalAmount);
- }
- else if(good.equalsIgnoreCase("G")) {
- this.wGeneral -= amount;
- held = player.getGeneralHeld();
- player.setGeneralHeld(held + finalAmount);
- }
- else if(good.equalsIgnoreCase("A")) {
- this.wArms -= amount;
- held = player.getArmsHeld();
- player.setArmsHeld(held + finalAmount);
- }
- }
- else {
- System.out.println("Sorry this transfer cannot be made");
- }
- }
-
+ /*private int wOpium = 0;
+ private int wSilk = 0;
+ private int wGeneral = 0;
+ private int wArms = 0;*/
+ private Player player;
- public void showWarehouse() {
- System.out.println("Opium : " + this.wOpium);
- System.out.println("Silk : " + this.wSilk);
- System.out.println("General : " + this.wGeneral);
- System.out.println("Arms : " + this.wArms);
- }
+ public void setPlayer(Player player) {
+ Player playerDumy = new Player(player);
+ this.player = playerDumy;
+ }
-
- public void changeWarehouse() {
- boolean keepGoing = true;
- while(keepGoing) {
- this.showWarehouse();
- String input = " ";
- System.out.println("Would you like to add(A) or remove(R) resources? ");
- Scanner keyboard = new Scanner(System.in);
- input = keyboard.next();
- if(input.equalsIgnoreCase("R")) {
- this.removeAmount();
- this.showWarehouse();
- }
- else if(input.equalsIgnoreCase("A")) {
- this.addAmount();
- this.showWarehouse();
- }
-
- String check;
- System.out.println("Would you like to do any other business? Y / N?");
+ public Player getPlayer() {
+ Player playerDummy = new Player(player);
+ return playerDummy;
+ }
+
+ public Warehouse(Player player) {
+ Player playerDummy = new Player(player);
+ this.player = playerDummy;
+ }
+
+
+ public void addAmount() {
+ 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.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;
+ }
+ 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 (player.getOpiumHeld() >= Integer.parseInt(amount)) {
+ player.setwOpium(player.getwOpium() + finalAmount);
+ held = player.getOpiumHeld();
+ player.setOpiumHeld(held - finalAmount);
+ System.out.println(player.getOpiumHeld());
+ } else {
+ System.out.println("You don't even have that much opium!");
+ }
+ } else if (good.equalsIgnoreCase("S")) {
+ if (player.getSilkHeld() >= Integer.parseInt(amount)) {
+ player.setwSilk(player.getwSilk() + finalAmount);
+ held = player.getSilkHeld();
+ player.setSilkHeld(held - finalAmount);
+ } else {
+ System.out.println("You don't even have that much silk!");
+
+ }
+ } else if (good.equalsIgnoreCase("G")) {
+ if (player.getGeneralHeld() >= Integer.parseInt(amount)) {
+ player.setwGeneral(player.getwGeneral() + finalAmount);
+ held = player.getGeneralHeld();
+ player.setGeneralHeld(held - finalAmount);
+ } else {
+ System.out.println("You don't even have that much general cargo!");
+
+ }
+ } else if (good.equalsIgnoreCase("A")) {
+ if (player.getArmsHeld() >= Integer.parseInt(amount)) {
+ player.setwArms(player.getwArms() + finalAmount);
+ held = player.getArmsHeld();
+ player.setArmsHeld(held - finalAmount);
+ } else {
+ System.out.println("You don't even have that much Arms!");
+ }
+ }
+ } 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() {
+ String amount;
+ boolean askGood = false;
+ 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.nextLine();
+ try {
+ 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);
+ 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 (player.getwOpium() >= Integer.parseInt(amount)) {
+ player.setwOpium(player.getwOpium() - 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 (player.getwSilk() >= Integer.parseInt(amount)) {
+ player.setwSilk(player.getwSilk() - 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 (player.getwGeneral() >= Integer.parseInt(amount)) {
+ player.setwGeneral(player.getwGeneral() - 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 (player.getwArms() >= Integer.parseInt(amount)) {
+ player.setwArms(player.getwArms() - 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");
+ }
+ }
+
+
+ public void showWarehouse() {
+ System.out.println("--------------------\nWarehouse\n--------------------");
+ System.out.println("Opium : " + player.getwOpium());
+ System.out.println("Silk : " + player.getwSilk());
+ System.out.println("General : " + player.getwGeneral());
+ System.out.println("Arms : " + player.getwArms());
+ }
+
+
+ public void changeWarehouse() {
+ boolean keepGoing = true;
+ while (keepGoing) {
+ this.showWarehouse();
+ String input = " ";
+ System.out.println("Would you like to add(A) or remove(R) resources? ");
+ Scanner keyboard = new Scanner(System.in);
+ input = keyboard.next();
+ if (input.equalsIgnoreCase("R")) {
+ this.removeAmount();
+ this.showWarehouse();
+ } else if (input.equalsIgnoreCase("A")) {
+ this.addAmount();
+ this.showWarehouse();
+
+ }
+ else{
+ System.out.println("Don't waste the warehouse's time, try again later with a valid input");
+ }
+
+ 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;
- }
- else if(check.equalsIgnoreCase("N")) {
- keepGoing = false;
- }
- }
- }
- public static void main(String[] args){
+ if (check.equalsIgnoreCase("Y")) {
+ keepGoing = true;
+ } else if (check.equalsIgnoreCase("N")) {
+ keepGoing = false;
+ }
+ }
+ }
+
+ public static void main(String[] args) {
}
}
diff --git a/src/loanShark.java b/src/loanShark.java
index f8298cf..4cfc87f 100644
--- a/src/loanShark.java
+++ b/src/loanShark.java
@@ -28,9 +28,15 @@ public class loanShark {
player.setDebt(player.getDebt() + loanAsk);
player.setMoney(player.getMoney() + loanAsk);
}
+ //updated
+ else{
+ System.out.println("Sorry you can't be loaned that much");
+ break;
+ }
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;