diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..217af47
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/description.html b/.idea/description.html
new file mode 100644
index 0000000..db5f129
--- /dev/null
+++ b/.idea/description.html
@@ -0,0 +1 @@
+Simple Java application that includes a class with main() method
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..ada92a5
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..e38587f
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..dfe61a7
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..45cf85c
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..bb0a2b6
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,337 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ C:\Users\Harkamal Randhawa\AppData\Roaming\Subversion
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1550454898506
+
+
+ 1550454898506
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No facets are configured
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+ TaipanClone
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.svn/entries b/.svn/entries
new file mode 100644
index 0000000..48082f7
--- /dev/null
+++ b/.svn/entries
@@ -0,0 +1 @@
+12
diff --git a/.svn/format b/.svn/format
new file mode 100644
index 0000000..48082f7
--- /dev/null
+++ b/.svn/format
@@ -0,0 +1 @@
+12
diff --git a/.svn/pristine/0f/0f5719e344fb5e944722f5cc9a0d1f45ffb592c3.svn-base b/.svn/pristine/0f/0f5719e344fb5e944722f5cc9a0d1f45ffb592c3.svn-base
new file mode 100644
index 0000000..dfe61a7
--- /dev/null
+++ b/.svn/pristine/0f/0f5719e344fb5e944722f5cc9a0d1f45ffb592c3.svn-base
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.svn/pristine/ae/ae924b6b0ddd88261e4cde2fd88ac2c5a40ac406.svn-base b/.svn/pristine/ae/ae924b6b0ddd88261e4cde2fd88ac2c5a40ac406.svn-base
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/.svn/pristine/ae/ae924b6b0ddd88261e4cde2fd88ac2c5a40ac406.svn-base
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.svn/pristine/ae/aeb18194e7bd7aabc4528b1d3292e14e972d3aa3.svn-base b/.svn/pristine/ae/aeb18194e7bd7aabc4528b1d3292e14e972d3aa3.svn-base
new file mode 100644
index 0000000..aa377e7
--- /dev/null
+++ b/.svn/pristine/ae/aeb18194e7bd7aabc4528b1d3292e14e972d3aa3.svn-base
@@ -0,0 +1,376 @@
+import java.util.Random;
+import java.util.Scanner;
+public class TaipanShop {
+
+ private String name = "Taipan";
+ private int bank = 0;
+ private int money = 1000;
+ private int opiumHeld = 0;
+ private int silkHeld = 0;
+ private int generalHeld = 0;
+ private int armsHeld = 0;
+ private int cargoSpace = 60;
+ private int currentCargo = 0;
+ private int opiumPrice = 16000;
+ private int silkPrice = 1600;
+ private int armsPrice = 160;
+ private int generalPrice = 8;
+ private int location = 2;
+ private int guns = 0;
+
+ public void updatePrices(){
+ String s = "\n" + name + ", the price of ";
+ double value = 80*Math.random();
+ Random rand = new Random();
+ opiumPrice = (rand.nextInt(201) + 60)*100;
+ silkPrice = (rand.nextInt(201) + 60)*10;
+ armsPrice = (rand.nextInt(21) + 6)*10;
+ generalPrice = rand.nextInt(17) + 4;
+ if(value < 8){
+ if(value < 2){
+ if(value < 1){
+ opiumPrice /= 5;
+ System.out.println(s + "Opium has dropped to " + opiumPrice +"!!!\n");
+ }else{
+ opiumPrice *= 5;
+ System.out.println(s + "Opium has risen to " + opiumPrice +"!!!\n");
+ }
+ }else if(value < 4){
+ if(value < 3){
+ silkPrice /= 5;
+ System.out.println(s + "Silk has dropped to " + silkPrice +"!!!\n");
+ }else{
+ silkPrice *= 5;
+ System.out.println(s + "Silk has risen to " + silkPrice +"!!!\n");
+ }
+ }else if(value < 6){
+ if(value < 3){
+ armsPrice /= 5;
+ System.out.println(s + "Arms has dropped to " + armsPrice +"!!!\n");
+ }else{
+ armsPrice *= 5;
+ System.out.println(s + "Arms has risen to " + armsPrice +"!!!\n");
+ }
+ }else{
+ if(value < 7){
+ generalPrice = 1;
+ System.out.println(s + "General Cargo has dropped to 1!!!\n");
+ }else{
+ generalPrice *= 5;
+ System.out.println(s + "General Cargo has risen to " + generalPrice + "!!!\n");
+ }
+ }
+ }
+ }
+
+ public void printShop(){
+ currentCargo = opiumHeld+guns*10+silkHeld+armsHeld+generalHeld;
+ if(cargoSpace - currentCargo < 0){
+ System.out.println("Hold: Overloaded" + " Guns: " + guns);
+ }else{
+ System.out.println("Hold: " + (cargoSpace-currentCargo) + " Guns: " + guns);
+ }
+ System.out.println("-------------------------------------------------------------");
+ System.out.println(" Opium: " + opiumHeld + " Silk: " + silkHeld);
+ System.out.println(" Arms: " + armsHeld + " General: " + generalHeld);
+ System.out.println("-------------------------------------------------------------");
+ System.out.println("Cash: " + money + " Bank: " + bank+"\n");
+ System.out.println(name + ", present prices per unit here are:");
+ System.out.println(" Opium: " + opiumPrice + " Silk: " + silkPrice);
+ System.out.println(" Arms: " + armsPrice + " General: " + generalPrice);
+ }
+
+ public void shop() {
+ updatePrices();
+ Scanner input = new Scanner(System.in);
+ boolean notDone = true;
+ if (location == 1) {
+ while (notDone) {
+ printShop();
+ System.out.println("\nShall I Buy, Sell, Visit Bank, Transfer Cargo, or Quit Trading?");
+ String response = input.next();
+ if (response.equalsIgnoreCase("B")) {
+ boolean notDone2 = true;
+ System.out.println("What do you wish me to buy, " + name + "?");
+ while (notDone2) {
+ response = input.nextLine();
+ if (response.equalsIgnoreCase("O")) {
+ System.out.println("\nHow much Opium shall I buy, " + name + "? (You can afford " + money / opiumPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / opiumPrice && num >= 0) {
+ opiumHeld += num;
+ money -= num * opiumPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Opium?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("S")) {
+ System.out.println("\nHow much Silk shall I buy, " + name + "? (You can afford " + money / silkPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / silkPrice && num >= 0) {
+ silkHeld += num;
+ money -= num * silkPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Silk?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("A")) {
+ System.out.println("\nHow many Arms shall I buy, " + name + "? (You can afford " + money / armsPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / armsPrice && num >= 0) {
+ armsHeld += num;
+ money -= num * armsPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Arms?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("G")) {
+ System.out.println("\nHow much General Cargo shall I buy, " + name + "? (You can afford " + money / generalPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / generalPrice && num >= 0) {
+ generalHeld += num;
+ money -= num * generalPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " General Cargo?");
+ }
+ }
+ }
+
+ }
+
+ } else if (response.equalsIgnoreCase("S")) {
+ boolean notDone2 = true;
+ System.out.println("What do you wish me to sell, " + name + "?");
+ while (notDone2) {
+ response = input.nextLine();
+ if (response.equalsIgnoreCase("O")) {
+ System.out.println("\nHow much Opium shall I sell, " + name + "? (You have " + opiumHeld + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= opiumHeld && num >= 0) {
+ opiumHeld -= num;
+ money += num * opiumPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Opium?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("S")) {
+ System.out.println("\nHow much Silk shall I sell, " + name + "? (You have " + silkHeld + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= silkHeld && num >= 0) {
+ silkHeld -= num;
+ money += num * silkPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Silk?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("A")) {
+ System.out.println("\nHow many Arms shall I sell, " + name + "? (You have " + armsHeld + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= armsHeld && num >= 0) {
+ armsHeld -= num;
+ money += num * armsPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Arms?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("G")) {
+ System.out.println("\nHow much General Cargo shall I sell, " + name + "? (You have " + generalHeld + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= generalHeld && num >= 0) {
+ generalHeld -= num;
+ money += num * generalPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " General Cargo?");
+ }
+ }
+ }
+
+ }
+
+ } else if (response.equalsIgnoreCase("V")) {
+ System.out.println("\n*** PLACEHOLDER FOR BANK ***\n");
+ } else if (response.equalsIgnoreCase("T")) {
+ System.out.println("\n*** PLACEHOLDER FOR WAREHOUSE ***\n");
+ } else if (response.equalsIgnoreCase("Q")) {
+ System.out.println("\n*** PLACEHOLDER FOR TRAVEL ***\n");
+ notDone = false;
+ }
+ }
+ } else {
+ while (notDone) {
+ printShop();
+ System.out.println("\nShall I Buy, Sell, or Quit Trading?");
+ String response = input.next();
+ if (response.equalsIgnoreCase("B")) {
+ boolean notDone2 = true;
+ System.out.println("What do you wish me to buy, " + name + "?");
+ while (notDone2) {
+ response = input.nextLine();
+ if (response.equalsIgnoreCase("O")) {
+ System.out.println("\nHow much Opium shall I buy, " + name + "? (You can afford " + money / opiumPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / opiumPrice && num >= 0) {
+ opiumHeld += num;
+ money -= num * opiumPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Opium?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("S")) {
+ System.out.println("\nHow much Silk shall I buy, " + name + "? (You can afford " + money / silkPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / silkPrice && num >= 0) {
+ silkHeld += num;
+ money -= num * silkPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Silk?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("A")) {
+ System.out.println("\nHow many Arms shall I buy, " + name + "? (You can afford " + money / armsPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / armsPrice && num >= 0) {
+ armsHeld += num;
+ money -= num * armsPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Arms?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("G")) {
+ System.out.println("\nHow much General Cargo shall I buy, " + name + "? (You can afford " + money / generalPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / generalPrice && num >= 0) {
+ generalHeld += num;
+ money -= num * generalPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " General Cargo?");
+ }
+ }
+ }
+
+ }
+
+ } else if (response.equalsIgnoreCase("S")) {
+ boolean notDone2 = true;
+ System.out.println("What do you wish me to sell, " + name + "? (You have " + opiumHeld + ")");
+ while (notDone2) {
+ response = input.nextLine();
+ if (response.equalsIgnoreCase("O")) {
+ System.out.println("\nHow much Opium shall I sell, " + name + "?");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= opiumHeld && num >= 0) {
+ opiumHeld -= num;
+ money += num * opiumPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Opium?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("S")) {
+ System.out.println("\nHow much Silk shall I sell, " + name + "? (You have " + silkHeld + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= silkHeld && num >= 0) {
+ silkHeld -= num;
+ money += num * silkPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Silk?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("A")) {
+ System.out.println("\nHow many Arms shall I sell, " + name + "? (You have " + armsHeld + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= armsHeld && num >= 0) {
+ armsHeld -= num;
+ money += num * armsPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Arms?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("G")) {
+ System.out.println("\nHow much General Cargo shall I sell, " + name + "? (You have " + generalHeld + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= generalHeld && num >= 0) {
+ generalHeld -= num;
+ money += num * generalPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " General Cargo?");
+ }
+ }
+ }
+ }
+ } else if (response.equalsIgnoreCase("Q")) {
+ System.out.println("\n*** PLACEHOLDER FOR TRAVEL ***\n");
+ notDone = false;
+ }
+ }
+
+ }
+ }
+ public static void main(String[] args){
+ TaipanShop shop = new TaipanShop();
+ shop.shop();
+ }
+}
\ No newline at end of file
diff --git a/.svn/pristine/b3/b3587415a547bb7117518fdccaddb68f38eb465d.svn-base b/.svn/pristine/b3/b3587415a547bb7117518fdccaddb68f38eb465d.svn-base
new file mode 100644
index 0000000..15a15b2
--- /dev/null
+++ b/.svn/pristine/b3/b3587415a547bb7117518fdccaddb68f38eb465d.svn-base
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.svn/pristine/c9/c92f3eb0ad1c70371e177a4d7d741f90af3f902c.svn-base b/.svn/pristine/c9/c92f3eb0ad1c70371e177a4d7d741f90af3f902c.svn-base
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.svn/pristine/c9/c92f3eb0ad1c70371e177a4d7d741f90af3f902c.svn-base
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.svn/pristine/ca/cafe17e1af84f116d2e262995e9c1531443fa7ea.svn-base b/.svn/pristine/ca/cafe17e1af84f116d2e262995e9c1531443fa7ea.svn-base
new file mode 100644
index 0000000..a26d191
--- /dev/null
+++ b/.svn/pristine/ca/cafe17e1af84f116d2e262995e9c1531443fa7ea.svn-base
@@ -0,0 +1,182 @@
+import java.util.InputMismatchException;
+import java.util.Scanner;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+public class ShipWarfare {
+
+ private int money = 100000000;
+ private int guns = 3;
+ private int hp = 100;
+ private int numOfPeasantShips= 0;
+
+
+
+ public void peasantFleetAttack() throws Exception{
+ Scanner userResponse = new Scanner(System.in);
+ setNumOfPeasantShips(numOfShips());
+ System.out.printf("By Golly! We have $%,d \nwe are being attacked by %d ships\n", getMoney(), getNumOfPeasantShips());
+ System.out.println("What do you want to do? Press \"f\" to fight, and \"r\" to run ");
+ while(true) {
+ try {
+ String response = userResponse.nextLine();
+ if (response.equalsIgnoreCase("f")) {
+ System.out.println("Ohh, fight ehh?");
+ fightShips(getNumOfPeasantShips());
+ }
+ else if(response.equalsIgnoreCase("r")){
+
+ }
+
+ } catch (InputMismatchException e) {
+ String response;
+ System.out.println("Sorry, that is not an acceptable input please try again");
+ response = userResponse.nextLine();
+ if (response.equalsIgnoreCase("f") || response.equalsIgnoreCase("r"))
+ break;
+ }
+ }
+
+ }
+
+ public int getMoney() {
+ return money;
+ }
+
+ public int getGuns() {
+ return guns;
+ }
+
+ public int getHp() {
+ return hp;
+ }
+
+ public int getNumOfPeasantShips() {
+ return numOfPeasantShips;
+ }
+
+ public void setHp(int hp) {
+ this.hp = hp;
+
+ }
+
+ public void setMoney(int money) {
+ this.money = money;
+ }
+
+ public void setGuns(int guns) {
+ this.guns = guns;
+ }
+ public void setNumOfPeasantShips(int numOfPeasantShips) {
+ this.numOfPeasantShips = numOfPeasantShips;
+ }
+
+ public void delayForASecond() throws Exception {
+ TimeUnit.SECONDS.sleep(1);
+ }
+
+ public void gameOver(){
+ System.out.flush();
+ System.out.println("Game over");
+ }
+
+ public int numOfShips(){
+
+ int numOfShipsAttacking = 0;
+ Random randomValue = new Random();
+
+ if (getMoney() <= 100000){
+ //Minimum one ship will attack, maximum 20
+ numOfShipsAttacking = randomValue.nextInt(20) + 1;
+ }
+
+ else if (getMoney() <= 200000){
+ //Minimum 30 Ships will attack, maximum 70
+ numOfShipsAttacking = randomValue.nextInt(40) + 30;
+ }
+
+ else if (getMoney() <= 500000){
+ //Minimum 50 ships will attack, maximum 140
+ numOfShipsAttacking = randomValue.nextInt(90) + 50;
+ }
+
+ else if (getMoney() > 1000000){
+ //Minimum 100 ships will attack, maximum 300 ships
+ numOfShipsAttacking = randomValue.nextInt(3) + 100;
+ }
+
+ return numOfShipsAttacking;
+
+ }
+
+
+
+
+ public void fightShips(int typeOfShip) throws Exception {
+
+ Random randomValue = new Random();
+ int shipsRemaining = typeOfShip;
+ int exitValue=0;
+
+ if(typeOfShip==getNumOfPeasantShips()) {
+ //Player volley
+ while (exitValue==0){
+ for (int i = 0; i < shipsRemaining; i++) {
+ for (int j = 0; j < getGuns(); j++) {
+ int hitOrMiss = randomValue.nextInt(2) + 1;
+ if (hitOrMiss == 2) {
+ shipsRemaining--;
+ if (shipsRemaining <= 0) {
+ exitValue = 1;
+ break;
+ }
+ System.out.println("Got eem");
+ delayForASecond();
+ } else {
+ System.out.println("ARRG! We missed captain");
+ delayForASecond();
+ }
+
+
+ }
+
+ if (shipsRemaining <= 0) {
+ exitValue = 1;
+ break;
+ }
+
+ System.out.printf("%d ships remaining\n", shipsRemaining);
+ System.out.println("Oh no, they are taking the offensive!");
+ delayForASecond();
+ //Computer volley
+ setHp(getHp() - randomValue.nextInt(10));
+ if(getHp()<=0){
+ exitValue=2;
+ break;
+ }
+ System.out.printf("EEK, we have %d health left\n", getHp());
+ delayForASecond();
+
+ }
+ }
+ if(exitValue==1) {
+ System.out.printf("Got eem!\nIt appears we have defeated the enemy fleet and made it out at %d health\n", hp);
+ }
+ else if(exitValue==2){
+ gameOver();
+ }
+
+ }
+ //Type of ship implied to be Liu Yen fleet
+
+ else{
+
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ ShipWarfare littyObject = new ShipWarfare();
+ littyObject.peasantFleetAttack();
+ }
+
+}
diff --git a/.svn/pristine/e2/e2a51faca6781e316ba907fb6c6c96f00be519c2.svn-base b/.svn/pristine/e2/e2a51faca6781e316ba907fb6c6c96f00be519c2.svn-base
new file mode 100644
index 0000000..975ddc1
--- /dev/null
+++ b/.svn/pristine/e2/e2a51faca6781e316ba907fb6c6c96f00be519c2.svn-base
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.svn/pristine/e5/e52fd513aa4fad038743ca4bb2199c3065815988.svn-base b/.svn/pristine/e5/e52fd513aa4fad038743ca4bb2199c3065815988.svn-base
new file mode 100644
index 0000000..5e26124
--- /dev/null
+++ b/.svn/pristine/e5/e52fd513aa4fad038743ca4bb2199c3065815988.svn-base
@@ -0,0 +1,2 @@
+# TaipanClone
+Computer Science 233 project, Winter 2019
diff --git a/.svn/pristine/f9/f9f863ca04a1de87216ddb782551757cb9138f3d.svn-base b/.svn/pristine/f9/f9f863ca04a1de87216ddb782551757cb9138f3d.svn-base
new file mode 100644
index 0000000..2fe2e78
--- /dev/null
+++ b/.svn/pristine/f9/f9f863ca04a1de87216ddb782551757cb9138f3d.svn-base
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.svn/wc.db b/.svn/wc.db
new file mode 100644
index 0000000..737f77b
Binary files /dev/null and b/.svn/wc.db differ
diff --git a/.svn/wc.db-journal b/.svn/wc.db-journal
new file mode 100644
index 0000000..e69de29
diff --git a/TaipanClone.iml b/TaipanClone.iml
new file mode 100644
index 0000000..d5c0743
--- /dev/null
+++ b/TaipanClone.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/out/production/TaipanClone/ShipWarfare.class b/out/production/TaipanClone/ShipWarfare.class
new file mode 100644
index 0000000..d06d8e7
Binary files /dev/null and b/out/production/TaipanClone/ShipWarfare.class differ
diff --git a/out/production/TaipanClone/TaipanShop.class b/out/production/TaipanClone/TaipanShop.class
new file mode 100644
index 0000000..958d424
Binary files /dev/null and b/out/production/TaipanClone/TaipanShop.class differ
diff --git a/src/ShipWarfare.java b/src/ShipWarfare.java
new file mode 100644
index 0000000..21523a7
--- /dev/null
+++ b/src/ShipWarfare.java
@@ -0,0 +1,182 @@
+import java.util.InputMismatchException;
+import java.util.Scanner;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+public class ShipWarfare {
+
+ private int money = 100000000;
+ private int guns = 3;
+ private int hp = 100;
+ private int numOfPeasantShips= 0;
+
+
+
+ public void peasantFleetAttack() throws Exception{
+ Scanner userResponse = new Scanner(System.in);
+ setNumOfPeasantShips(numOfShips());
+ System.out.printf("By Golly! We have $%,d \nwe are being attacked by %d ships\n", getMoney(), getNumOfPeasantShips());
+ System.out.println("What do you want to do? Press \"f\" to fight, and \"r\" to run ");
+ while(true) {
+ try {
+ String response = userResponse.nextLine();
+ if (response.equalsIgnoreCase("f")) {
+ System.out.println("Ohh, fight ehh?");
+ fightShips(getNumOfPeasantShips());
+ }
+ else if(response.equalsIgnoreCase("r")){
+
+ }
+
+ } catch (InputMismatchException e) {
+ String response;
+ System.out.println("Sorry, that is not an acceptable input please try again");
+ response = userResponse.nextLine();
+ if (response.equalsIgnoreCase("f") || response.equalsIgnoreCase("r"))
+ break;
+ }
+ }
+
+ }
+
+ public int getMoney() {
+ return money;
+ }
+
+ public int getGuns() {
+ return guns;
+ }
+
+ public int getHp() {
+ return hp;
+ }
+
+ public int getNumOfPeasantShips() {
+ return numOfPeasantShips;
+ }
+
+ public void setHp(int hp) {
+ this.hp = hp;
+
+ }
+
+ public void setMoney(int money) {
+ this.money = money;
+ }
+
+ public void setGuns(int guns) {
+ this.guns = guns;
+ }
+ public void setNumOfPeasantShips(int numOfPeasantShips) {
+ this.numOfPeasantShips = numOfPeasantShips;
+ }
+
+ public void delayForASecond() throws Exception {
+ TimeUnit.SECONDS.sleep(1);
+ }
+
+ public void gameOver(){
+ System.out.flush();
+ System.out.println("Game over");
+ }
+
+ public int numOfShips(){
+
+ int numOfShipsAttacking = 0;
+ Random randomValue = new Random();
+
+ if (getMoney() <= 100000){
+ //Minimum one ship will attack, maximum 20
+ numOfShipsAttacking = randomValue.nextInt(20) + 1;
+ }
+
+ else if (getMoney() <= 200000){
+ //Minimum 30 Ships will attack, maximum 70
+ numOfShipsAttacking = randomValue.nextInt(40) + 30;
+ }
+
+ else if (getMoney() <= 500000){
+ //Minimum 50 ships will attack, maximum 140
+ numOfShipsAttacking = randomValue.nextInt(90) + 50;
+ }
+
+ else if (getMoney() > 1000000){
+ //Minimum 100 ships will attack, maximum 300 ships
+ numOfShipsAttacking = randomValue.nextInt(3) + 100;
+ }
+
+ return numOfShipsAttacking;
+
+ }
+
+
+
+
+ public void fightShips(int typeOfShip) throws Exception {
+
+ Random randomValue = new Random();
+ int shipsRemaining = typeOfShip;
+ int exitValue=0;
+
+ if(typeOfShip==getNumOfPeasantShips()) {
+ //Player volley
+ while (exitValue==0){
+ for (int i = 0; i < shipsRemaining; i++) {
+ for (int j = 0; j < getGuns(); j++) {
+ int hitOrMiss = randomValue.nextInt(2) + 1;
+ if (hitOrMiss == 2) {
+ shipsRemaining--;
+ if (shipsRemaining <= 0) {
+ exitValue = 1;
+ break;
+ }
+ System.out.println("Got eem");
+ delayForASecond();
+ } else {
+ System.out.println("ARRG! We missed captain");
+ delayForASecond();
+ }
+
+
+ }
+
+ if (shipsRemaining <= 0) {
+ exitValue = 1;
+ break;
+ }
+
+ System.out.printf("%d ships remaining\n", shipsRemaining);
+ System.out.println("Oh no, they are taking the offensive!");
+ delayForASecond();
+ //Computer volley
+ setHp(getHp() - randomValue.nextInt(10));
+ if(getHp()<=0){
+ exitValue=2;
+ break;
+ }
+ System.out.printf("EEK, we have %d health left\n", getHp());
+ delayForASecond();
+
+ }
+ }
+ if(exitValue==1) {
+ System.out.printf("Got eem!\nIt appears we have defeated the enemy fleet and made it out at %d health\n", hp);
+ }
+ else if(exitValue==2){
+ gameOver();
+ }
+
+ }
+ //Type of ship implied to be Liu Yen fleet
+
+ else{
+
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ ShipWarfare littyObject = new ShipWarfare();
+ littyObject.peasantFleetAttack();
+ }
+
+}
\ No newline at end of file
diff --git a/src/TaipanShop.java b/src/TaipanShop.java
new file mode 100644
index 0000000..aa377e7
--- /dev/null
+++ b/src/TaipanShop.java
@@ -0,0 +1,376 @@
+import java.util.Random;
+import java.util.Scanner;
+public class TaipanShop {
+
+ private String name = "Taipan";
+ private int bank = 0;
+ private int money = 1000;
+ private int opiumHeld = 0;
+ private int silkHeld = 0;
+ private int generalHeld = 0;
+ private int armsHeld = 0;
+ private int cargoSpace = 60;
+ private int currentCargo = 0;
+ private int opiumPrice = 16000;
+ private int silkPrice = 1600;
+ private int armsPrice = 160;
+ private int generalPrice = 8;
+ private int location = 2;
+ private int guns = 0;
+
+ public void updatePrices(){
+ String s = "\n" + name + ", the price of ";
+ double value = 80*Math.random();
+ Random rand = new Random();
+ opiumPrice = (rand.nextInt(201) + 60)*100;
+ silkPrice = (rand.nextInt(201) + 60)*10;
+ armsPrice = (rand.nextInt(21) + 6)*10;
+ generalPrice = rand.nextInt(17) + 4;
+ if(value < 8){
+ if(value < 2){
+ if(value < 1){
+ opiumPrice /= 5;
+ System.out.println(s + "Opium has dropped to " + opiumPrice +"!!!\n");
+ }else{
+ opiumPrice *= 5;
+ System.out.println(s + "Opium has risen to " + opiumPrice +"!!!\n");
+ }
+ }else if(value < 4){
+ if(value < 3){
+ silkPrice /= 5;
+ System.out.println(s + "Silk has dropped to " + silkPrice +"!!!\n");
+ }else{
+ silkPrice *= 5;
+ System.out.println(s + "Silk has risen to " + silkPrice +"!!!\n");
+ }
+ }else if(value < 6){
+ if(value < 3){
+ armsPrice /= 5;
+ System.out.println(s + "Arms has dropped to " + armsPrice +"!!!\n");
+ }else{
+ armsPrice *= 5;
+ System.out.println(s + "Arms has risen to " + armsPrice +"!!!\n");
+ }
+ }else{
+ if(value < 7){
+ generalPrice = 1;
+ System.out.println(s + "General Cargo has dropped to 1!!!\n");
+ }else{
+ generalPrice *= 5;
+ System.out.println(s + "General Cargo has risen to " + generalPrice + "!!!\n");
+ }
+ }
+ }
+ }
+
+ public void printShop(){
+ currentCargo = opiumHeld+guns*10+silkHeld+armsHeld+generalHeld;
+ if(cargoSpace - currentCargo < 0){
+ System.out.println("Hold: Overloaded" + " Guns: " + guns);
+ }else{
+ System.out.println("Hold: " + (cargoSpace-currentCargo) + " Guns: " + guns);
+ }
+ System.out.println("-------------------------------------------------------------");
+ System.out.println(" Opium: " + opiumHeld + " Silk: " + silkHeld);
+ System.out.println(" Arms: " + armsHeld + " General: " + generalHeld);
+ System.out.println("-------------------------------------------------------------");
+ System.out.println("Cash: " + money + " Bank: " + bank+"\n");
+ System.out.println(name + ", present prices per unit here are:");
+ System.out.println(" Opium: " + opiumPrice + " Silk: " + silkPrice);
+ System.out.println(" Arms: " + armsPrice + " General: " + generalPrice);
+ }
+
+ public void shop() {
+ updatePrices();
+ Scanner input = new Scanner(System.in);
+ boolean notDone = true;
+ if (location == 1) {
+ while (notDone) {
+ printShop();
+ System.out.println("\nShall I Buy, Sell, Visit Bank, Transfer Cargo, or Quit Trading?");
+ String response = input.next();
+ if (response.equalsIgnoreCase("B")) {
+ boolean notDone2 = true;
+ System.out.println("What do you wish me to buy, " + name + "?");
+ while (notDone2) {
+ response = input.nextLine();
+ if (response.equalsIgnoreCase("O")) {
+ System.out.println("\nHow much Opium shall I buy, " + name + "? (You can afford " + money / opiumPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / opiumPrice && num >= 0) {
+ opiumHeld += num;
+ money -= num * opiumPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Opium?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("S")) {
+ System.out.println("\nHow much Silk shall I buy, " + name + "? (You can afford " + money / silkPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / silkPrice && num >= 0) {
+ silkHeld += num;
+ money -= num * silkPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Silk?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("A")) {
+ System.out.println("\nHow many Arms shall I buy, " + name + "? (You can afford " + money / armsPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / armsPrice && num >= 0) {
+ armsHeld += num;
+ money -= num * armsPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Arms?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("G")) {
+ System.out.println("\nHow much General Cargo shall I buy, " + name + "? (You can afford " + money / generalPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / generalPrice && num >= 0) {
+ generalHeld += num;
+ money -= num * generalPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " General Cargo?");
+ }
+ }
+ }
+
+ }
+
+ } else if (response.equalsIgnoreCase("S")) {
+ boolean notDone2 = true;
+ System.out.println("What do you wish me to sell, " + name + "?");
+ while (notDone2) {
+ response = input.nextLine();
+ if (response.equalsIgnoreCase("O")) {
+ System.out.println("\nHow much Opium shall I sell, " + name + "? (You have " + opiumHeld + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= opiumHeld && num >= 0) {
+ opiumHeld -= num;
+ money += num * opiumPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Opium?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("S")) {
+ System.out.println("\nHow much Silk shall I sell, " + name + "? (You have " + silkHeld + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= silkHeld && num >= 0) {
+ silkHeld -= num;
+ money += num * silkPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Silk?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("A")) {
+ System.out.println("\nHow many Arms shall I sell, " + name + "? (You have " + armsHeld + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= armsHeld && num >= 0) {
+ armsHeld -= num;
+ money += num * armsPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Arms?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("G")) {
+ System.out.println("\nHow much General Cargo shall I sell, " + name + "? (You have " + generalHeld + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= generalHeld && num >= 0) {
+ generalHeld -= num;
+ money += num * generalPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " General Cargo?");
+ }
+ }
+ }
+
+ }
+
+ } else if (response.equalsIgnoreCase("V")) {
+ System.out.println("\n*** PLACEHOLDER FOR BANK ***\n");
+ } else if (response.equalsIgnoreCase("T")) {
+ System.out.println("\n*** PLACEHOLDER FOR WAREHOUSE ***\n");
+ } else if (response.equalsIgnoreCase("Q")) {
+ System.out.println("\n*** PLACEHOLDER FOR TRAVEL ***\n");
+ notDone = false;
+ }
+ }
+ } else {
+ while (notDone) {
+ printShop();
+ System.out.println("\nShall I Buy, Sell, or Quit Trading?");
+ String response = input.next();
+ if (response.equalsIgnoreCase("B")) {
+ boolean notDone2 = true;
+ System.out.println("What do you wish me to buy, " + name + "?");
+ while (notDone2) {
+ response = input.nextLine();
+ if (response.equalsIgnoreCase("O")) {
+ System.out.println("\nHow much Opium shall I buy, " + name + "? (You can afford " + money / opiumPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / opiumPrice && num >= 0) {
+ opiumHeld += num;
+ money -= num * opiumPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Opium?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("S")) {
+ System.out.println("\nHow much Silk shall I buy, " + name + "? (You can afford " + money / silkPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / silkPrice && num >= 0) {
+ silkHeld += num;
+ money -= num * silkPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Silk?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("A")) {
+ System.out.println("\nHow many Arms shall I buy, " + name + "? (You can afford " + money / armsPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / armsPrice && num >= 0) {
+ armsHeld += num;
+ money -= num * armsPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Arms?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("G")) {
+ System.out.println("\nHow much General Cargo shall I buy, " + name + "? (You can afford " + money / generalPrice + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= money / generalPrice && num >= 0) {
+ generalHeld += num;
+ money -= num * generalPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you can't afford that!");
+ } else {
+ System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " General Cargo?");
+ }
+ }
+ }
+
+ }
+
+ } else if (response.equalsIgnoreCase("S")) {
+ boolean notDone2 = true;
+ System.out.println("What do you wish me to sell, " + name + "? (You have " + opiumHeld + ")");
+ while (notDone2) {
+ response = input.nextLine();
+ if (response.equalsIgnoreCase("O")) {
+ System.out.println("\nHow much Opium shall I sell, " + name + "?");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= opiumHeld && num >= 0) {
+ opiumHeld -= num;
+ money += num * opiumPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Opium?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("S")) {
+ System.out.println("\nHow much Silk shall I sell, " + name + "? (You have " + silkHeld + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= silkHeld && num >= 0) {
+ silkHeld -= num;
+ money += num * silkPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Silk?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("A")) {
+ System.out.println("\nHow many Arms shall I sell, " + name + "? (You have " + armsHeld + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= armsHeld && num >= 0) {
+ armsHeld -= num;
+ money += num * armsPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Arms?");
+ }
+ }
+ } else if (response.equalsIgnoreCase("G")) {
+ System.out.println("\nHow much General Cargo shall I sell, " + name + "? (You have " + generalHeld + ")");
+ while (notDone2) {
+ int num = input.nextInt();
+ if (num <= generalHeld && num >= 0) {
+ generalHeld -= num;
+ money += num * generalPrice;
+ notDone2 = false;
+ } else if (num >= 0) {
+ System.out.println(name + ", you don't have that many to sell!");
+ } else {
+ System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " General Cargo?");
+ }
+ }
+ }
+ }
+ } else if (response.equalsIgnoreCase("Q")) {
+ System.out.println("\n*** PLACEHOLDER FOR TRAVEL ***\n");
+ notDone = false;
+ }
+ }
+
+ }
+ }
+ public static void main(String[] args){
+ TaipanShop shop = new TaipanShop();
+ shop.shop();
+ }
+}
\ No newline at end of file