From 5f1e566c8f2d5a5f0c75be730a3fcd1badc5634d Mon Sep 17 00:00:00 2001
From: KahootChampion
Date: Sun, 24 Feb 2019 19:56:16 -0700
Subject: [PATCH 01/17] Worked On Sid's class a bit
---
.idea/misc.xml | 2 +-
.idea/workspace.xml | 147 ++++++++++++++++++++-----------------------
src/ShipWarfare.java | 2 +-
src/Warehouse.java | 113 +++++++++++++++++----------------
4 files changed, 126 insertions(+), 138 deletions(-)
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 @@
-
+
+
+
+
+
+
@@ -26,19 +31,10 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -46,30 +42,26 @@
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
@@ -77,17 +69,17 @@
-
-
+
+
-
+
-
-
+
+
@@ -96,10 +88,10 @@
-
+
-
-
+
+
@@ -115,7 +107,6 @@
- eek
setg
guns
duplic
@@ -145,6 +136,7 @@
set
player.
System.out.println("\n*** PLACEHOLDER FOR LOAN SHARK ***\n");
+ keep
player.getName()
@@ -163,6 +155,7 @@
+
@@ -171,13 +164,13 @@
-
+
@@ -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;
From 1be615fcc46d20e9667255aadf88b9033cb7de00 Mon Sep 17 00:00:00 2001
From: KahootChampion
Date: Sun, 24 Feb 2019 20:26:05 -0700
Subject: [PATCH 02/17] Think I fixed Sid's code
---
.idea/workspace.xml | 29 ++--
src/Warehouse.java | 348 ++++++++++++++++++++++++--------------------
2 files changed, 207 insertions(+), 170 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index d6f0198..5730a80 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,9 +2,7 @@
-
-
@@ -60,8 +58,8 @@
-
-
+
+
@@ -208,7 +206,7 @@
-
+
@@ -424,14 +422,22 @@
1551060038524
-
+
+ 1551063376717
+
+
+
+ 1551063376717
+
+
-
+
+
@@ -442,7 +448,7 @@
-
+
@@ -486,7 +492,8 @@
-
+
+
@@ -560,8 +567,8 @@
-
-
+
+
diff --git a/src/Warehouse.java b/src/Warehouse.java
index 7ed5feb..b27d851 100644
--- a/src/Warehouse.java
+++ b/src/Warehouse.java
@@ -1,169 +1,199 @@
import java.util.Scanner;
public class Warehouse {
- private int wOpium = 0;
- 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() {
- 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")) {
- 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() {
- 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.nextLine();
- if(Integer.parseInt(amount) <= this.wOpium) {
- finalAmount = Integer.parseInt(amount);
- }
- else if(Integer.parseInt(amount) <= this.wSilk) {
- finalAmount = Integer.parseInt(amount);
- }
- else if(Integer.parseInt(amount) <= this.wGeneral) {
- finalAmount = Integer.parseInt(amount);
- }
- else if(Integer.parseInt(amount) <= this.wArms) {
- finalAmount = Integer.parseInt(amount);
- }
-
-
- 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 -= Integer.parseInt(amount);
- held = player.getOpiumHeld();
- player.setOpiumHeld(held + finalAmount);
- }
- else if(good.equalsIgnoreCase("S")) {
- this.wSilk -= Integer.parseInt(amount);
- held = player.getSilkHeld();
- player.setSilkHeld(held + finalAmount);
- }
- else if(good.equalsIgnoreCase("G")) {
- this.wGeneral -= Integer.parseInt(amount);
- held = player.getGeneralHeld();
- player.setGeneralHeld(held + finalAmount);
- }
- else if(good.equalsIgnoreCase("A")) {
- this.wArms -= Integer.parseInt(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?");
- check = keyboard.nextLine();
- check=keyboard.nextLine();
-
- if(check.equalsIgnoreCase("Y")) {
- keepGoing = true;
- }
- else if(check.equalsIgnoreCase("N")) {
- keepGoing = false;
- }
- }
- }
+ public Player getPlayer() {
+ Player playerDummy = new Player(player);
+ return playerDummy;
+ }
- public static void main(String[] args){
+ 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)) {
+ this.wOpium += 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)) {
+ this.wSilk += 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)) {
+ this.wGeneral += 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)) {
+ this.wArms += 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();
+ if (Integer.parseInt(amount) <= wOpium || Integer.parseInt(amount) <=wSilk || Integer.parseInt(amount) <= wGeneral || Integer.parseInt(amount) <= wArms) {
+ 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 (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");
+ }
+ }
+ }
+
+
+ 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 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?");
+ 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) {
}
}
From c59f06b127763546c8389fe19e5ce532df4e39ec Mon Sep 17 00:00:00 2001
From: KahootChampion
Date: Sun, 24 Feb 2019 20:30:47 -0700
Subject: [PATCH 03/17] Small thing, changed an output of warehouse a bit,
shows user its the warehosue they are concerned with.
---
.idea/workspace.xml | 26 +++++++++++++++++---------
src/Warehouse.java | 1 +
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5730a80..9f58b02 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -58,8 +58,8 @@
-
-
+
+
@@ -206,7 +206,7 @@
-
+
@@ -429,11 +429,18 @@
1551063376717
-
+
+ 1551065166040
+
+
+
+ 1551065166040
+
+
-
+
@@ -448,7 +455,7 @@
-
+
@@ -493,7 +500,8 @@
-
+
+
@@ -567,8 +575,8 @@
-
-
+
+
diff --git a/src/Warehouse.java b/src/Warehouse.java
index b27d851..5d8e324 100644
--- a/src/Warehouse.java
+++ b/src/Warehouse.java
@@ -157,6 +157,7 @@ public class Warehouse {
public void showWarehouse() {
+ System.out.println("--------------------\nWarehouse\n--------------------");
System.out.println("Opium : " + this.wOpium);
System.out.println("Silk : " + this.wSilk);
System.out.println("General : " + this.wGeneral);
From 9f23ec187c87e0ee8affdbaba744e83a767088e2 Mon Sep 17 00:00:00 2001
From: KahootChampion
Date: Sun, 24 Feb 2019 20:38:00 -0700
Subject: [PATCH 04/17] Forgot a try catch in warehouse
---
.idea/workspace.xml | 48 +++++++++++---------
src/Warehouse.java | 107 ++++++++++++++++++++++----------------------
2 files changed, 82 insertions(+), 73 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 9f58b02..cb51149 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -58,8 +58,8 @@
-
-
+
+
@@ -88,8 +88,8 @@
-
-
+
+
@@ -105,7 +105,6 @@
- setg
guns
duplic
chanceOfRun
@@ -135,6 +134,7 @@
player.
System.out.println("\n*** PLACEHOLDER FOR LOAN SHARK ***\n");
keep
+ showWa
player.getName()
@@ -206,7 +206,7 @@
-
+
@@ -436,17 +436,24 @@
1551065166040
-
+
+ 1551065447444
+
+
+
+ 1551065447444
+
+
-
+
-
+
@@ -455,7 +462,7 @@
-
+
@@ -501,7 +508,8 @@
-
+
+
@@ -556,13 +564,6 @@
-
-
-
-
-
-
-
@@ -573,10 +574,17 @@
+
+
+
+
+
+
+
-
-
+
+
diff --git a/src/Warehouse.java b/src/Warehouse.java
index 5d8e324..538f418 100644
--- a/src/Warehouse.java
+++ b/src/Warehouse.java
@@ -97,61 +97,62 @@ public class Warehouse {
System.out.println("Please enter the amount of the good you would like to REMOVE");
Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextLine();
- if (Integer.parseInt(amount) <= wOpium || Integer.parseInt(amount) <=wSilk || Integer.parseInt(amount) <= wGeneral || Integer.parseInt(amount) <= wArms) {
- 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 (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!");
-
- }
- }
+ try {
+ if (Integer.parseInt(amount) <= wOpium || Integer.parseInt(amount) <= wSilk || Integer.parseInt(amount) <= wGeneral || Integer.parseInt(amount) <= wArms) {
+ finalAmount = Integer.parseInt(amount);
+ askGood = true;
} 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");
}
}
From 3ecc99a87999e6b004521dc70540027d1aa2070e Mon Sep 17 00:00:00 2001
From: Siddhant Dewani
Date: Sun, 24 Feb 2019 21:24:45 -0700
Subject: [PATCH 05/17] Small thing, changed an output of warehouse a bit,
shows user its the warehouse they are concerned with.
---
src/Player.java | 41 +++++++++++++++++++++++++++++++++++++++++
src/Warehouse.java | 40 ++++++++++++++++++++--------------------
2 files changed, 61 insertions(+), 20 deletions(-)
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 538f418..d2ea689 100644
--- a/src/Warehouse.java
+++ b/src/Warehouse.java
@@ -1,10 +1,10 @@
import java.util.Scanner;
public class Warehouse {
- private int wOpium = 0;
+ /*private int wOpium = 0;
private int wSilk = 0;
private int wGeneral = 0;
- private int wArms = 0;
+ private int wArms = 0;*/
private Player player;
@@ -47,7 +47,7 @@ public class Warehouse {
if (Integer.parseInt(amount) > 0) {
if (good.equalsIgnoreCase("O")) {
if (player.getOpiumHeld() >= Integer.parseInt(amount)) {
- this.wOpium += finalAmount;
+ player.setwOpium(player.getwOpium() + finalAmount);
held = player.getOpiumHeld();
player.setOpiumHeld(held - finalAmount);
System.out.println(player.getOpiumHeld());
@@ -56,7 +56,7 @@ public class Warehouse {
}
} else if (good.equalsIgnoreCase("S")) {
if (player.getSilkHeld() >= Integer.parseInt(amount)) {
- this.wSilk += finalAmount;
+ player.setwSilk(player.getwSilk() + finalAmount);
held = player.getSilkHeld();
player.setSilkHeld(held - finalAmount);
} else {
@@ -65,7 +65,7 @@ public class Warehouse {
}
} else if (good.equalsIgnoreCase("G")) {
if (player.getGeneralHeld() >= Integer.parseInt(amount)) {
- this.wGeneral += finalAmount;
+ player.setwGeneral(player.getwGeneral() + finalAmount);
held = player.getGeneralHeld();
player.setGeneralHeld(held - finalAmount);
} else {
@@ -74,7 +74,7 @@ public class Warehouse {
}
} else if (good.equalsIgnoreCase("A")) {
if (player.getArmsHeld() >= Integer.parseInt(amount)) {
- this.wArms += finalAmount;
+ player.setwArms(player.getwArms() + finalAmount);
held = player.getArmsHeld();
player.setArmsHeld(held - finalAmount);
} else {
@@ -98,7 +98,7 @@ public class Warehouse {
Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextLine();
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);
askGood = true;
} else {
@@ -113,24 +113,24 @@ public class Warehouse {
int held = 0;
if (Integer.parseInt(amount) > 0) {
if (good.equalsIgnoreCase("O")) {
- if (this.wOpium >= Integer.parseInt(amount)) {
- this.wOpium -= Integer.parseInt(amount);
+ 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 (this.wSilk >= Integer.parseInt(amount)) {
- this.wSilk -= Integer.parseInt(amount);
+ 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 (this.wGeneral >= Integer.parseInt(amount)) {
- this.wGeneral -= Integer.parseInt(amount);
+ if (player.getwGeneral() >= Integer.parseInt(amount)) {
+ player.setwGeneral(player.getwGeneral() - Integer.parseInt(amount));
held = player.getGeneralHeld();
player.setGeneralHeld(held + finalAmount);
} else {
@@ -138,8 +138,8 @@ public class Warehouse {
}
} else if (good.equalsIgnoreCase("A")) {
- if (this.wArms >= Integer.parseInt(amount)) {
- this.wArms -= Integer.parseInt(amount);
+ if (player.getwArms() >= Integer.parseInt(amount)) {
+ player.setwArms(player.getwArms() - Integer.parseInt(amount));
held = player.getArmsHeld();
player.setArmsHeld(held + finalAmount);
} else {
@@ -159,10 +159,10 @@ public class Warehouse {
public void showWarehouse() {
System.out.println("--------------------\nWarehouse\n--------------------");
- System.out.println("Opium : " + this.wOpium);
- System.out.println("Silk : " + this.wSilk);
- System.out.println("General : " + this.wGeneral);
- System.out.println("Arms : " + this.wArms);
+ System.out.println("Opium : " + player.getwOpium());
+ System.out.println("Silk : " + player.getwSilk());
+ System.out.println("General : " + player.getwGeneral());
+ System.out.println("Arms : " + player.getwArms());
}
@@ -185,7 +185,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();
+ check = keyboard.nextLine();
if (check.equalsIgnoreCase("Y")) {
keepGoing = true;
From e495f6e1bbc746d16fec24e21b6aef4c50ab6d39 Mon Sep 17 00:00:00 2001
From: KahootChampion
Date: Sun, 24 Feb 2019 21:33:20 -0700
Subject: [PATCH 06/17] Sneaky bug in shipWarfare regarding having 0 guns is
now fixed.
---
.idea/workspace.xml | 153 +++++++++++++++++--------------------------
src/ShipWarfare.java | 130 ++++++++++++++++++++----------------
2 files changed, 132 insertions(+), 151 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index cb51149..6a320d6 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,7 +3,7 @@
-
+
@@ -27,57 +27,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -85,15 +49,6 @@
-
-
-
-
-
-
-
-
-
@@ -105,7 +60,6 @@
- guns
duplic
chanceOfRun
chance
@@ -135,6 +89,7 @@
System.out.println("\n*** PLACEHOLDER FOR LOAN SHARK ***\n");
keep
showWa
+ player.get
player.getName()
@@ -160,15 +115,15 @@
@@ -183,7 +138,6 @@
-
@@ -201,12 +155,13 @@
+
-
+
@@ -302,6 +257,8 @@
+
+
1550458807806
@@ -443,17 +400,24 @@
1551065447444
-
+
+ 1551065880809
+
+
+
+ 1551065880809
+
+
-
+
-
+
@@ -462,7 +426,7 @@
-
+
@@ -471,7 +435,7 @@
-
+
@@ -509,7 +473,8 @@
-
+
+
@@ -536,27 +501,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -564,16 +508,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -581,13 +515,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ShipWarfare.java b/src/ShipWarfare.java
index fc29444..79d3e03 100644
--- a/src/ShipWarfare.java
+++ b/src/ShipWarfare.java
@@ -15,12 +15,12 @@ public class ShipWarfare extends Player {
private int numOfLittyShips = 0;
private boolean userAttacks = true;
private int startingPeasantShips = 0;
- private int startingLittyShips =0;
+ private int startingLittyShips = 0;
private int howMuchRun = 0;
private String pirateName = "Liu Yen";
private Player player;
- public ShipWarfare(Player player){
+ public ShipWarfare(Player player) {
Player playerDummy = new Player(player);
this.player = playerDummy;
}
@@ -30,11 +30,11 @@ public class ShipWarfare extends Player {
this.player = playerDummy;
}
- public Player getPlayer(){
+ public Player getPlayer() {
Player playerDummy = new Player(player);
return playerDummy;
}
-
+
//This fleet is easy to defeat as a maximum of 15 ships can run away each volley, they can not tank hits
public void peasantFleetAttack() throws Exception {
Scanner userResponse = new Scanner(System.in);
@@ -70,6 +70,7 @@ public class ShipWarfare extends Player {
}
+
//This fleet is difficult to defeat as a maximum of 10 ships can run away each volley, they can tank hits
public void littyFleetAttack() throws Exception {
Scanner userResponse = new Scanner(System.in);
@@ -180,29 +181,33 @@ public class ShipWarfare extends Player {
//Player volley
while (exitValue == 0) {
- for (int j = 0; j < player.getGuns(); j++) {
- if (userAttacks == true) {
- int hitOrMiss = randomValue.nextInt(3) + 1;
- if (hitOrMiss == 1) {
- numOfLittyShips--;
- if (numOfLittyShips <= 0) {
- exitValue = 1;
- break;
+ if (player.getGuns() > 0) {
+ for (int j = 0; j < player.getGuns(); j++) {
+ if (userAttacks == true) {
+ int hitOrMiss = randomValue.nextInt(3) + 1;
+ if (hitOrMiss == 1) {
+ numOfLittyShips--;
+ if (numOfLittyShips <= 0) {
+ exitValue = 1;
+ break;
+ }
+ System.out.println("Got eem");
+ delayForASecond();
+ } else if (hitOrMiss == 2) {
+ System.out.printf("ARRG! We missed %s\n", getName());
+ delayForASecond();
+ } else {
+ System.out.println("Darn! Their fleet tanked our attack");
+ delayForASecond();
}
- System.out.println("Got eem");
- delayForASecond();
- } else if (hitOrMiss == 2) {
- System.out.printf("ARRG! We missed %s\n", getName());
- delayForASecond();
+
+
} else {
- System.out.println("Darn! Their fleet tanked our attack");
- delayForASecond();
+ continue;
}
-
-
- } else {
- continue;
}
+ } else {
+ System.out.println("Captain! We don't have any GUNS!!!!");
}
@@ -210,17 +215,19 @@ public class ShipWarfare extends Player {
exitValue = 1;
break;
}
- chanceOfEnemyRun = randomValue.nextInt(2) + 1;
- if (chanceOfEnemyRun == 2) {
- howMuchRun = randomValue.nextInt(10) + 1;
- if (howMuchRun != 0 && howMuchRun < numOfLittyShips) {
+ if (player.getGuns() > 0) {
+ if (chanceOfEnemyRun == 2) {
+ chanceOfEnemyRun = randomValue.nextInt(2) + 1;
+ howMuchRun = randomValue.nextInt(10) + 1;
+ if (howMuchRun != 0 && howMuchRun < numOfLittyShips) {
- setNumOfLittyShips(numOfLittyShips - howMuchRun);
- if (userAttacks == true) {
- System.out.printf("Cowards! %d ships ran away %s!\n", howMuchRun, getName());
- } else {
- System.out.printf("Escaped %d of them!\n", howMuchRun);
+ setNumOfLittyShips(numOfLittyShips - howMuchRun);
+ if (userAttacks == true) {
+ System.out.printf("Cowards! %d ships ran away %s!\n", howMuchRun, getName());
+ } else {
+ System.out.printf("Escaped %d of them!\n", howMuchRun);
+ }
}
}
}
@@ -292,44 +299,53 @@ public class ShipWarfare extends Player {
//Player volley
while (exitValue == 0) {
- for (int j = 0; j < player.getGuns(); j++) {
- if (userAttacks == true) {
- int hitOrMiss = randomValue.nextInt(2) + 1;
- if (hitOrMiss == 2) {
- numOfPeasantShips--;
- if (numOfPeasantShips <= 0) {
- exitValue = 1;
- break;
+ if (player.getGuns() > 0) {
+
+ for (int j = 0; j < player.getGuns(); j++) {
+ if (userAttacks == true) {
+ int hitOrMiss = randomValue.nextInt(2) + 1;
+ if (hitOrMiss == 2) {
+ numOfPeasantShips--;
+ if (numOfPeasantShips <= 0) {
+ exitValue = 1;
+ break;
+ }
+ System.out.println("Got eem");
+ delayForASecond();
+ } else {
+ System.out.printf("ARRG! We missed %s\n", getName());
+ delayForASecond();
}
- System.out.println("Got eem");
- delayForASecond();
+
+
} else {
- System.out.printf("ARRG! We missed %s\n", getName());
- delayForASecond();
+ continue;
}
-
-
- } else {
- continue;
}
}
+ else{
+ System.out.println("Captain! We don't have any GUNS!!!!");
+
+ }
if (numOfPeasantShips <= 0) {
exitValue = 1;
break;
}
- chanceOfEnemyRun = randomValue.nextInt(2) + 1;
- if (chanceOfEnemyRun == 2) {
- howMuchRun = randomValue.nextInt(15) + 1;
- if (howMuchRun != 0 && howMuchRun < numOfPeasantShips) {
+ if (player.getGuns() > 0) {
+ chanceOfEnemyRun = randomValue.nextInt(2) + 1;
+ if (chanceOfEnemyRun == 2) {
+ howMuchRun = randomValue.nextInt(15) + 1;
+ if (howMuchRun != 0 && howMuchRun < numOfPeasantShips) {
- setNumOfPeasantShips(numOfPeasantShips - howMuchRun);
- if (userAttacks == true) {
- System.out.printf("Ahhh, %d ships ran away %s!\n", howMuchRun, getName());
- } else {
- System.out.printf("Escaped %d of them!\n", howMuchRun);
+ setNumOfPeasantShips(numOfPeasantShips - howMuchRun);
+ if (userAttacks == true) {
+ System.out.printf("Ahhh, %d ships ran away %s!\n", howMuchRun, getName());
+ } else {
+ System.out.printf("Escaped %d of them!\n", howMuchRun);
+ }
}
}
}
From 5d9c371e84b58402d0d2328c4e14fe3ad6d6cb12 Mon Sep 17 00:00:00 2001
From: KahootChampion
Date: Sun, 24 Feb 2019 21:40:20 -0700
Subject: [PATCH 07/17] Really small change in Sid's code that no one will
probably ever notice lol
---
out/production/TaipanClone/ShipWarfare.class | Bin 7254 -> 7385 bytes
src/Warehouse.java | 4 ++++
2 files changed, 4 insertions(+)
diff --git a/out/production/TaipanClone/ShipWarfare.class b/out/production/TaipanClone/ShipWarfare.class
index 967eead28c13a693b6d65a19d793967a66a473ba..73760e7243e93b87bab6da59e75b285dc0413d2f 100644
GIT binary patch
delta 3409
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
diff --git a/src/Warehouse.java b/src/Warehouse.java
index d2ea689..016ad5d 100644
--- a/src/Warehouse.java
+++ b/src/Warehouse.java
@@ -180,6 +180,10 @@ public class Warehouse {
} 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;
From 9f84e23a10f10f81f28f59bad4009b798a416214 Mon Sep 17 00:00:00 2001
From: Siddhant Dewani
Date: Sun, 24 Feb 2019 21:34:01 -0700
Subject: [PATCH 08/17] Small thing, changed an output of warehouse a bit,
shows user its the warehouse they are concerned with.
---
src/loanShark.java | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/loanShark.java b/src/loanShark.java
index f8298cf..20dab5a 100644
--- a/src/loanShark.java
+++ b/src/loanShark.java
@@ -1,5 +1,7 @@
import java.util.Scanner;
+import static javafx.application.Platform.exit;
+
public class loanShark {
private Player player;
public void setPlayer(Player player) {
@@ -28,9 +30,14 @@ public class loanShark {
player.setDebt(player.getDebt() + loanAsk);
player.setMoney(player.getMoney() + loanAsk);
}
+ else{
+ System.out.println("Sorry you cant 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;
From d50058f0562a8258982f0f9f429bd29d7bf7cf46 Mon Sep 17 00:00:00 2001
From: Siddhant Dewani
Date: Sun, 24 Feb 2019 21:39:01 -0700
Subject: [PATCH 09/17] Small thing, changed an output of warehouse a bit,
shows user its the warehouse they are concerned with.
---
src/loanShark.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/loanShark.java b/src/loanShark.java
index 20dab5a..387a3b4 100644
--- a/src/loanShark.java
+++ b/src/loanShark.java
@@ -30,6 +30,7 @@ public class loanShark {
player.setDebt(player.getDebt() + loanAsk);
player.setMoney(player.getMoney() + loanAsk);
}
+ //updated
else{
System.out.println("Sorry you cant be loaned that much");
break;
From e31587ecdc33ca2578804d635d41d605ec2cd600 Mon Sep 17 00:00:00 2001
From: Siddhant Dewani
Date: Sun, 24 Feb 2019 21:47:05 -0700
Subject: [PATCH 10/17] Small thing, changed an output of warehouse a bit,
shows user its the warehouse they are concerned with.
---
src/loanShark.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/loanShark.java b/src/loanShark.java
index 387a3b4..8d15674 100644
--- a/src/loanShark.java
+++ b/src/loanShark.java
@@ -32,7 +32,7 @@ public class loanShark {
}
//updated
else{
- System.out.println("Sorry you cant be loaned that much");
+ System.out.println("Sorry you can't be loaned that much");
break;
}
String check;
From 081892ea6d0cd01dd270fc402515aab757c3c9f0 Mon Sep 17 00:00:00 2001
From: Siddhant Dewani
Date: Sun, 24 Feb 2019 21:57:53 -0700
Subject: [PATCH 11/17] Small thing, changed an output of warehouse a bit,
shows user its the warehouse they are concerned with.
---
src/Bank.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/Bank.java b/src/Bank.java
index 6d3ca6a..a2f6676 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());
From 1959f63821faeb364895de0fc89197a2534bb54f Mon Sep 17 00:00:00 2001
From: Siddhant Dewani
Date: Sun, 24 Feb 2019 22:01:02 -0700
Subject: [PATCH 12/17] Small thing, changed an output of warehouse a bit,
shows user its the warehouse they are concerned with.
---
src/Bank.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Bank.java b/src/Bank.java
index a2f6676..604927f 100644
--- a/src/Bank.java
+++ b/src/Bank.java
@@ -29,7 +29,7 @@ public class Bank{
if(response.equalsIgnoreCase("W")){
boolean notDone2 = true;
while(notDone2){
- System.out.println("How much do you wish to Withdraw");
+ System.out.println("How much do you wish to Withdraw?");
int withdraw = input.nextInt();
if(withdraw <= player.getBank()){
player.setMoney(withdraw + player.getMoney());
@@ -41,7 +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");
+ System.out.println("How much do you wish to Deposit?");
int deposit = input.nextInt();
if(deposit <= player.getMoney()){
player.setBank(deposit + player.getBank());
From f6f0c960ea940fce87e1ad21637c0ee6d8f3a553 Mon Sep 17 00:00:00 2001
From: Siddhant Dewani
Date: Sun, 24 Feb 2019 22:03:32 -0700
Subject: [PATCH 13/17] Small thing, changed an output of warehouse a bit,
shows user its the warehouse they are concerned with.
---
src/Bank.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Bank.java b/src/Bank.java
index 604927f..b76f423 100644
--- a/src/Bank.java
+++ b/src/Bank.java
@@ -56,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")){
From ae0e9c4659867bf676442c00769a84a069952a43 Mon Sep 17 00:00:00 2001
From: KahootChampion
Date: Sun, 24 Feb 2019 23:06:05 -0700
Subject: [PATCH 14/17] Changed the timing in ShipWarfare
---
.idea/workspace.xml | 187 +++++++++++++++++++++++++++----------------
src/ShipWarfare.java | 45 +++++++----
src/loanShark.java | 2 -
3 files changed, 147 insertions(+), 87 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 6a320d6..8ac0a84 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,9 +1,10 @@
-
+
+
@@ -29,10 +30,10 @@
-
+
-
-
+
+
@@ -40,8 +41,38 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -60,15 +91,6 @@
- duplic
- chanceOfRun
- chance
- get
- Peasant
- d
- captain
- printf
- liu
howmuchRun
setPlayer
setNumOf
@@ -90,6 +112,15 @@
keep
showWa
player.get
+ throws Exception
+ would
+ .nextInt
+ getName
+ we made it
+ delayfora
+ dela
+ couldn
+ GUNS
player.getName()
@@ -105,10 +136,10 @@
player.set
%s
loan();
+ throws InterruptedException
-
@@ -116,13 +147,13 @@
-
-
-
+
+
+
@@ -258,7 +289,7 @@
-
+
1550458807806
@@ -407,11 +438,25 @@
1551065880809
-
+
+ 1551069200511
+
+
+
+ 1551069200512
+
+
+ 1551069620616
+
+
+
+ 1551069620616
+
+
-
+
@@ -426,7 +471,7 @@
-
+
@@ -474,7 +519,9 @@
-
+
+
+
@@ -484,44 +531,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -529,24 +538,62 @@
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
diff --git a/src/ShipWarfare.java b/src/ShipWarfare.java
index 79d3e03..f2d948e 100644
--- a/src/ShipWarfare.java
+++ b/src/ShipWarfare.java
@@ -48,6 +48,7 @@ public class ShipWarfare extends Player {
if (response.equalsIgnoreCase("f")) {
userAttacks = true;
System.out.println("Ohh, fight ehh?");
+ delayForSeconds(1);
boolean winOrLose = destroyPeasantShipsOrEscape();
if (winOrLose == true) {
break;
@@ -61,6 +62,7 @@ public class ShipWarfare extends Player {
break;
} else {
System.out.println("Phew! Got away safely");
+ delayForSeconds(2);
break;
}
@@ -91,10 +93,12 @@ public class ShipWarfare extends Player {
} else if (response.equalsIgnoreCase("r")) {
if (runFromShips() == false) {
System.out.println("Couldn't run away!");
+ delayForSeconds(1);
if (destroyLittyShipsOrEscape())
break;
} else {
System.out.println("Phew! Got away safely");
+ delayForSeconds(2);
break;
}
@@ -107,7 +111,7 @@ public class ShipWarfare extends Player {
public void fightOrRunMessage() {
- System.out.printf("What do you want to do? Enter \"f\" to fight, and \"r\" to run (we have %d guns)", player.getGuns());
+ System.out.printf("What do you want to do? Enter \"f\" to fight, and \"r\" to run (we have %d guns)\n", player.getGuns());
}
@@ -128,8 +132,8 @@ public class ShipWarfare extends Player {
}
- public void delayForASecond() throws Exception {
- TimeUnit.SECONDS.sleep(1);
+ public void delayForSeconds(int num) throws Exception {
+ TimeUnit.SECONDS.sleep(num);
}
//The number of ships which attack is based on the amount of money one has on hand
@@ -192,13 +196,13 @@ public class ShipWarfare extends Player {
break;
}
System.out.println("Got eem");
- delayForASecond();
+ delayForSeconds(1);
} else if (hitOrMiss == 2) {
System.out.printf("ARRG! We missed %s\n", getName());
- delayForASecond();
+ delayForSeconds(1);
} else {
System.out.println("Darn! Their fleet tanked our attack");
- delayForASecond();
+ delayForSeconds(1);
}
@@ -207,7 +211,8 @@ public class ShipWarfare extends Player {
}
}
} else {
- System.out.println("Captain! We don't have any GUNS!!!!");
+ System.out.printf("%s! We don't have any GUNS!!!!\n",player.getName());
+ delayForSeconds(1);
}
@@ -234,7 +239,7 @@ public class ShipWarfare extends Player {
System.out.printf("%d ships remaining\n", numOfLittyShips);
System.out.println("Oh no, they are taking the offensive!");
- delayForASecond();
+ delayForSeconds(1);
//Computer volley
int takeGunChance = randomValue.nextInt(4) + 1;
if (takeGunChance == 1 && player.getGuns() > 0) {
@@ -248,7 +253,7 @@ public class ShipWarfare extends Player {
break;
}
System.out.printf("EEK, our current ship status is %d%% \n", player.getHP());
- delayForASecond();
+ delayForSeconds(1);
if (userAttacks == false) {
userAttacks = true;
}
@@ -259,8 +264,10 @@ public class ShipWarfare extends Player {
if (response.equalsIgnoreCase("r")) {
if (runFromShips() == false) {
System.out.println("Couldn't run away");
+ delayForSeconds(1);
} else {
- exitValue = 3;
+ System.out.println("Phew! Got away safely");
+ delayForSeconds(2);
break;
}
}
@@ -271,15 +278,18 @@ public class ShipWarfare extends Player {
if (exitValue == 1) {
System.out.printf("\nGot eem\nVictory!\nIt appears we have defeated the enemy fleet and made it out at %d%% ship status\n", player.getHP());
+ delayForSeconds(1);
calculateLoot = (randomValue.nextInt(startingLittyShips) + startingLittyShips) * 300;
player.setMoney(player.getMoney() + calculateLoot);
System.out.printf("We got $%,d!\n", calculateLoot);
+ delayForSeconds(2);
return true;
} else if (exitValue == 2) {
gameOver();
return true;
} else if (exitValue == 3) {
System.out.printf("We made it out at %d%% ship status!\n", player.getHP());
+ delayForSeconds(2);
return true;
}
return false;
@@ -311,10 +321,10 @@ public class ShipWarfare extends Player {
break;
}
System.out.println("Got eem");
- delayForASecond();
+ delayForSeconds(1);
} else {
System.out.printf("ARRG! We missed %s\n", getName());
- delayForASecond();
+ delayForSeconds(1);
}
@@ -324,7 +334,8 @@ public class ShipWarfare extends Player {
}
}
else{
- System.out.println("Captain! We don't have any GUNS!!!!");
+ System.out.printf("%s! We don't have any GUNS!!!!\n", player.getName());
+ delayForSeconds(1);
}
@@ -351,8 +362,9 @@ public class ShipWarfare extends Player {
}
System.out.printf("%d ships remaining\n", numOfPeasantShips);
+ delayForSeconds(1);
System.out.println("Oh no, they are taking the offensive!");
- delayForASecond();
+ delayForSeconds(1);
//Computer volley
int takeGunChance = randomValue.nextInt(4) + 1;
if (takeGunChance == 1 && player.getGuns() > 0) {
@@ -366,7 +378,7 @@ public class ShipWarfare extends Player {
break;
}
System.out.printf("EEK, our current ship status is %d%% \n", player.getHP());
- delayForASecond();
+ delayForSeconds(1);
if (userAttacks == false) {
userAttacks = true;
}
@@ -389,15 +401,18 @@ public class ShipWarfare extends Player {
if (exitValue == 1) {
System.out.printf("\nGot eem\nVictory!\nIt appears we have defeated the enemy fleet and made it out at %d%% ship status\n", player.getHP());
+ delayForSeconds(1);
calculateLoot = (randomValue.nextInt(startingPeasantShips) + startingPeasantShips) * 100;
player.setMoney(player.getMoney() + calculateLoot);
System.out.printf("We got $%,d!", calculateLoot);
+ delayForSeconds(2);
return true;
} else if (exitValue == 2) {
gameOver();
return true;
} else if (exitValue == 3) {
System.out.printf("We made it out at %d%% ship status!\n", player.getHP());
+ delayForSeconds(2);
return true;
}
return false;
diff --git a/src/loanShark.java b/src/loanShark.java
index 8d15674..4cfc87f 100644
--- a/src/loanShark.java
+++ b/src/loanShark.java
@@ -1,7 +1,5 @@
import java.util.Scanner;
-import static javafx.application.Platform.exit;
-
public class loanShark {
private Player player;
public void setPlayer(Player player) {
From ecb5072a06a81d603d1b0b766ceb57a813966e86 Mon Sep 17 00:00:00 2001
From: Vikramb987 <47336882+Vikramb987@users.noreply.github.com>
Date: Mon, 25 Feb 2019 07:21:07 -0700
Subject: [PATCH 15/17] Create README.md
---
README.md | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 README.md
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..16dbae8
--- /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"(Opium), "S"(Silk), "A"(Arms), "G"(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.
From 602e93138792db6765ae55528ae74205acf7d291 Mon Sep 17 00:00:00 2001
From: Vikramb987 <47336882+Vikramb987@users.noreply.github.com>
Date: Mon, 25 Feb 2019 07:22:25 -0700
Subject: [PATCH 16/17] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 16dbae8..893c2b0 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,6 @@ 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"(Opium), "S"(Silk), "A"(Arms), "G"(General cargo).
+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.
From 600fe404d560db64d6b3fb6fc4c5cf1e0db218b3 Mon Sep 17 00:00:00 2001
From: Vikramb987 <47336882+Vikramb987@users.noreply.github.com>
Date: Mon, 25 Feb 2019 07:35:41 -0700
Subject: [PATCH 17/17] Update ShipWarfare.java
somehow, the comment doesn't let me compile the file.
---
src/ShipWarfare.java | 7 -------
1 file changed, 7 deletions(-)
diff --git a/src/ShipWarfare.java b/src/ShipWarfare.java
index f2d948e..7866f63 100644
--- a/src/ShipWarfare.java
+++ b/src/ShipWarfare.java
@@ -2,13 +2,6 @@ import java.util.Scanner;
import java.util.Random;
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 {
private int numOfPeasantShips = 0;