From ee071d52671e932721dd5a5b892af4aa17275abd Mon Sep 17 00:00:00 2001 From: Solargale Date: Sun, 17 Feb 2019 19:11:07 -0700 Subject: [PATCH] deleting old files before adding updated project --- .idea/TaipanClone.iml | 11 -- .idea/encodings.xml | 4 - .idea/misc.xml | 7 - .idea/modules.xml | 8 - .idea/vcs.xml | 6 - README.md | 2 - TaipanClone.iml | 11 -- src/ShipWarfare.java | 182 -------------------- src/TaipanShop.java | 376 ------------------------------------------ 9 files changed, 607 deletions(-) delete mode 100644 .idea/TaipanClone.iml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 README.md delete mode 100644 TaipanClone.iml delete mode 100644 src/ShipWarfare.java delete mode 100644 src/TaipanShop.java diff --git a/.idea/TaipanClone.iml b/.idea/TaipanClone.iml deleted file mode 100644 index c90834f..0000000 --- a/.idea/TaipanClone.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 15a15b2..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 975ddc1..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index dfe61a7..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 5e26124..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# TaipanClone -Computer Science 233 project, Winter 2019 diff --git a/TaipanClone.iml b/TaipanClone.iml deleted file mode 100644 index 2fe2e78..0000000 --- a/TaipanClone.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/src/ShipWarfare.java b/src/ShipWarfare.java deleted file mode 100644 index a26d191..0000000 --- a/src/ShipWarfare.java +++ /dev/null @@ -1,182 +0,0 @@ -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/src/TaipanShop.java b/src/TaipanShop.java deleted file mode 100644 index aa377e7..0000000 --- a/src/TaipanShop.java +++ /dev/null @@ -1,376 +0,0 @@ -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