Merge remote-tracking branch 'origin/master'
# Conflicts: # .idea/workspace.xml # src/ShipWarfare.java
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -3,7 +3,7 @@
|
|||||||
<component name="ProjectKey">
|
<component name="ProjectKey">
|
||||||
<option name="state" value="project://63537948-39a4-48a0-9c97-34259a0fa913" />
|
<option name="state" value="project://63537948-39a4-48a0-9c97-34259a0fa913" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8.0_191" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8.0_201" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
<component name="SvnBranchConfigurationManager">
|
<component name="SvnBranchConfigurationManager">
|
||||||
|
|||||||
8
README.md
Normal file
8
README.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# TaipanClone
|
||||||
|
Computer Science 233 project, Winter 2019
|
||||||
|
|
||||||
|
To run the program, please go to src>start.java and run that program.
|
||||||
|
For input, the program usually takes the first letter of whichever option you need to select. Example:
|
||||||
|
What would you like to buy? Valid inputs are "O" (for Opium), "S" (for Silk), "A" (for Arms), "G" (for General cargo).
|
||||||
|
|
||||||
|
You lose if your HP reaches 0. You can win if you "retire" in Hong Kong while having a net worth of over $1 million.
|
||||||
Binary file not shown.
@@ -29,6 +29,7 @@ public class Bank{
|
|||||||
if(response.equalsIgnoreCase("W")){
|
if(response.equalsIgnoreCase("W")){
|
||||||
boolean notDone2 = true;
|
boolean notDone2 = true;
|
||||||
while(notDone2){
|
while(notDone2){
|
||||||
|
System.out.println("How much do you wish to Withdraw?");
|
||||||
int withdraw = input.nextInt();
|
int withdraw = input.nextInt();
|
||||||
if(withdraw <= player.getBank()){
|
if(withdraw <= player.getBank()){
|
||||||
player.setMoney(withdraw + player.getMoney());
|
player.setMoney(withdraw + player.getMoney());
|
||||||
@@ -40,6 +41,7 @@ public class Bank{
|
|||||||
}else if(response.equalsIgnoreCase("D")){
|
}else if(response.equalsIgnoreCase("D")){
|
||||||
boolean notDone2 = true;
|
boolean notDone2 = true;
|
||||||
while(notDone2){
|
while(notDone2){
|
||||||
|
System.out.println("How much do you wish to Deposit?");
|
||||||
int deposit = input.nextInt();
|
int deposit = input.nextInt();
|
||||||
if(deposit <= player.getMoney()){
|
if(deposit <= player.getMoney()){
|
||||||
player.setBank(deposit + player.getBank());
|
player.setBank(deposit + player.getBank());
|
||||||
@@ -54,6 +56,7 @@ public class Bank{
|
|||||||
while(notDone3){
|
while(notDone3){
|
||||||
System.out.println("Would you like to continue? Y/N");
|
System.out.println("Would you like to continue? Y/N");
|
||||||
response = input.nextLine();
|
response = input.nextLine();
|
||||||
|
response = input.nextLine();
|
||||||
if(response.equalsIgnoreCase("Y")){
|
if(response.equalsIgnoreCase("Y")){
|
||||||
notDone3 = false;
|
notDone3 = false;
|
||||||
}else if(response.equalsIgnoreCase("N")){
|
}else if(response.equalsIgnoreCase("N")){
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ public class Player {
|
|||||||
private int guns = 0;
|
private int guns = 0;
|
||||||
private int HP = 100;
|
private int HP = 100;
|
||||||
private int debt = 0;
|
private int debt = 0;
|
||||||
|
private int wOpium = 0;
|
||||||
|
private int wSilk = 0;
|
||||||
|
private int wGeneral = 0;
|
||||||
|
private int wArms = 0;
|
||||||
private boolean retire = false;
|
private boolean retire = false;
|
||||||
|
|
||||||
public Player(){
|
public Player(){
|
||||||
@@ -28,6 +32,11 @@ public class Player {
|
|||||||
this.guns = player.guns;
|
this.guns = player.guns;
|
||||||
this.HP = player.HP;
|
this.HP = player.HP;
|
||||||
this.debt = player.debt;
|
this.debt = player.debt;
|
||||||
|
this.wOpium = player.wOpium;
|
||||||
|
this.wSilk = player.wSilk;
|
||||||
|
this.wGeneral = player.wGeneral;
|
||||||
|
this.wArms = player.wArms;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getRetire(){
|
public boolean getRetire(){
|
||||||
@@ -148,6 +157,38 @@ public class Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getwOpium(){ return wOpium; }
|
||||||
|
|
||||||
|
public void setwOpium(int wOpium) {
|
||||||
|
if (wOpium >= 0){
|
||||||
|
this.wOpium = wOpium;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getwSilk(){return wSilk;}
|
||||||
|
|
||||||
|
public void setwSilk(int wSilk) {
|
||||||
|
if (wSilk >= 0){
|
||||||
|
this.wSilk = wSilk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getwGeneral(){return wGeneral;}
|
||||||
|
|
||||||
|
public void setwGeneral(int wGeneral) {
|
||||||
|
if (wGeneral >= 0){
|
||||||
|
this.wGeneral = wGeneral;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getwArms(){return wArms;}
|
||||||
|
|
||||||
|
public void setwArms(int wArms) {
|
||||||
|
if (wArms >= 0){
|
||||||
|
this.wArms = wArms;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void gameOver(){
|
public void gameOver(){
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
System.out.println("Game over");
|
System.out.println("Game over");
|
||||||
|
|||||||
@@ -1,170 +1,205 @@
|
|||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Warehouse {
|
public class Warehouse {
|
||||||
private int wOpium = 25;
|
/*private int wOpium = 0;
|
||||||
private int wSilk = 0;
|
private int wSilk = 0;
|
||||||
private int wGeneral = 0;
|
private int wGeneral = 0;
|
||||||
private int wArms = 0;
|
private int wArms = 0;*/
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
||||||
|
|
||||||
public void setPlayer(Player player) {
|
public void setPlayer(Player player) {
|
||||||
Player playerDumy = new Player(player);
|
Player playerDumy = new Player(player);
|
||||||
this.player= playerDumy;
|
this.player = playerDumy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer(){
|
public Player getPlayer() {
|
||||||
Player playerDummy = new Player(player);
|
Player playerDummy = new Player(player);
|
||||||
return playerDummy;
|
return playerDummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Warehouse(Player player){
|
public Warehouse(Player player) {
|
||||||
Player playerDummy = new Player(player);
|
Player playerDummy = new Player(player);
|
||||||
this.player = playerDummy;
|
this.player = playerDummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addAmount() {
|
public void addAmount() {
|
||||||
int amount = 0;
|
boolean askGood = false;
|
||||||
|
String amount;
|
||||||
int finalAmount = 0;
|
int finalAmount = 0;
|
||||||
System.out.println("Please enter the amount of the good you would like to ADD.");
|
System.out.println("Please enter the amount of the good you would like to ADD.");
|
||||||
Scanner keyboard = new Scanner(System.in);
|
Scanner keyboard = new Scanner(System.in);
|
||||||
amount = keyboard.nextInt();
|
amount = keyboard.nextLine();
|
||||||
if(amount <= player.getOpiumHeld()) {
|
try {
|
||||||
finalAmount = amount;
|
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);
|
||||||
else if(amount <= player.getSilkHeld()) {
|
askGood = true;
|
||||||
finalAmount = amount;
|
} else {
|
||||||
}
|
System.out.println("Nice try but you don't have any items of that quantity!");
|
||||||
else if(amount <= player.getGeneralHeld()) {
|
askGood = false;
|
||||||
finalAmount = amount;
|
|
||||||
}
|
|
||||||
else if(amount <= player.getArmsHeld()) {
|
|
||||||
finalAmount = amount;
|
|
||||||
}
|
}
|
||||||
|
if (askGood == true) {
|
||||||
String good;
|
String good;
|
||||||
System.out.println("Please enter a good to transfer O, S, G, A :");
|
System.out.println("Please enter a good to transfer O, S, G, A :");
|
||||||
good = keyboard.nextLine();
|
good = keyboard.nextLine();
|
||||||
int held = 0;
|
int held = 0;
|
||||||
if (amount > 0) {
|
if (Integer.parseInt(amount) > 0) {
|
||||||
if (good.equalsIgnoreCase("O")) {
|
if (good.equalsIgnoreCase("O")) {
|
||||||
this.wOpium += finalAmount;
|
if (player.getOpiumHeld() >= Integer.parseInt(amount)) {
|
||||||
|
player.setwOpium(player.getwOpium() + finalAmount);
|
||||||
held = player.getOpiumHeld();
|
held = player.getOpiumHeld();
|
||||||
player.setOpiumHeld(held - finalAmount);
|
player.setOpiumHeld(held - finalAmount);
|
||||||
System.out.println(player.getOpiumHeld());
|
System.out.println(player.getOpiumHeld());
|
||||||
|
} else {
|
||||||
|
System.out.println("You don't even have that much opium!");
|
||||||
}
|
}
|
||||||
else if(good.equalsIgnoreCase("S")) {
|
} else if (good.equalsIgnoreCase("S")) {
|
||||||
this.wSilk += finalAmount;
|
if (player.getSilkHeld() >= Integer.parseInt(amount)) {
|
||||||
|
player.setwSilk(player.getwSilk() + finalAmount);
|
||||||
held = player.getSilkHeld();
|
held = player.getSilkHeld();
|
||||||
player.setSilkHeld(held - finalAmount);
|
player.setSilkHeld(held - finalAmount);
|
||||||
|
} else {
|
||||||
|
System.out.println("You don't even have that much silk!");
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(good.equalsIgnoreCase("G")) {
|
} else if (good.equalsIgnoreCase("G")) {
|
||||||
this.wGeneral += finalAmount;
|
if (player.getGeneralHeld() >= Integer.parseInt(amount)) {
|
||||||
|
player.setwGeneral(player.getwGeneral() + finalAmount);
|
||||||
held = player.getGeneralHeld();
|
held = player.getGeneralHeld();
|
||||||
player.setGeneralHeld(held - finalAmount);
|
player.setGeneralHeld(held - finalAmount);
|
||||||
|
} else {
|
||||||
|
System.out.println("You don't even have that much general cargo!");
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(good.equalsIgnoreCase("A")) {
|
} else if (good.equalsIgnoreCase("A")) {
|
||||||
this.wArms += finalAmount;
|
if (player.getArmsHeld() >= Integer.parseInt(amount)) {
|
||||||
|
player.setwArms(player.getwArms() + finalAmount);
|
||||||
held = player.getArmsHeld();
|
held = player.getArmsHeld();
|
||||||
player.setArmsHeld(held - finalAmount);
|
player.setArmsHeld(held - finalAmount);
|
||||||
|
} else {
|
||||||
|
System.out.println("You don't even have that much Arms!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
System.out.println("Sorry this transfer cannot be made");
|
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() {
|
public void removeAmount() {
|
||||||
int amount = 0;
|
String amount;
|
||||||
|
boolean askGood = false;
|
||||||
int finalAmount = 0;
|
int finalAmount = 0;
|
||||||
System.out.println("Please enter the amount of the good you would like to REMOVE");
|
System.out.println("Please enter the amount of the good you would like to REMOVE");
|
||||||
Scanner keyboard = new Scanner(System.in);
|
Scanner keyboard = new Scanner(System.in);
|
||||||
amount = keyboard.nextInt();
|
amount = keyboard.nextLine();
|
||||||
if(amount <= this.wOpium) {
|
try {
|
||||||
finalAmount = amount;
|
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);
|
||||||
else if(amount <= this.wSilk) {
|
askGood = true;
|
||||||
finalAmount = amount;
|
} else {
|
||||||
}
|
System.out.println("Nice try but you don't have any items of that quantity in the warehouse!");
|
||||||
else if(amount <= this.wGeneral) {
|
askGood = false;
|
||||||
finalAmount = amount;
|
|
||||||
}
|
|
||||||
else if(amount <= this.wArms) {
|
|
||||||
finalAmount = amount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (askGood == true) {
|
||||||
String good;
|
String good;
|
||||||
System.out.println("Please enter a good to transfer O, S, G, A :");
|
System.out.println("Please enter a good to transfer O, S, G, A :");
|
||||||
good = keyboard.nextLine();
|
good = keyboard.nextLine();
|
||||||
int held = 0;
|
int held = 0;
|
||||||
if (amount > 0) {
|
if (Integer.parseInt(amount) > 0) {
|
||||||
if (good.equalsIgnoreCase("O")) {
|
if (good.equalsIgnoreCase("O")) {
|
||||||
this.wOpium -= amount;
|
if (player.getwOpium() >= Integer.parseInt(amount)) {
|
||||||
|
player.setwOpium(player.getwOpium() - Integer.parseInt(amount));
|
||||||
held = player.getOpiumHeld();
|
held = player.getOpiumHeld();
|
||||||
player.setOpiumHeld(held + finalAmount);
|
player.setOpiumHeld(held + finalAmount);
|
||||||
|
} else {
|
||||||
|
System.out.println("You don't have that much opium stored in the warehouse!");
|
||||||
}
|
}
|
||||||
else if(good.equalsIgnoreCase("S")) {
|
} else if (good.equalsIgnoreCase("S")) {
|
||||||
this.wSilk -= amount;
|
if (player.getwSilk() >= Integer.parseInt(amount)) {
|
||||||
|
player.setwSilk(player.getwSilk() - Integer.parseInt(amount));
|
||||||
held = player.getSilkHeld();
|
held = player.getSilkHeld();
|
||||||
player.setSilkHeld(held + finalAmount);
|
player.setSilkHeld(held + finalAmount);
|
||||||
|
} else {
|
||||||
|
System.out.println("You don't have that much silk stored in the warehouse!");
|
||||||
}
|
}
|
||||||
else if(good.equalsIgnoreCase("G")) {
|
} else if (good.equalsIgnoreCase("G")) {
|
||||||
this.wGeneral -= amount;
|
if (player.getwGeneral() >= Integer.parseInt(amount)) {
|
||||||
|
player.setwGeneral(player.getwGeneral() - Integer.parseInt(amount));
|
||||||
held = player.getGeneralHeld();
|
held = player.getGeneralHeld();
|
||||||
player.setGeneralHeld(held + finalAmount);
|
player.setGeneralHeld(held + finalAmount);
|
||||||
|
} else {
|
||||||
|
System.out.println("You don't have that much general cargo stored in the warehouse!");
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(good.equalsIgnoreCase("A")) {
|
} else if (good.equalsIgnoreCase("A")) {
|
||||||
this.wArms -= amount;
|
if (player.getwArms() >= Integer.parseInt(amount)) {
|
||||||
|
player.setwArms(player.getwArms() - Integer.parseInt(amount));
|
||||||
held = player.getArmsHeld();
|
held = player.getArmsHeld();
|
||||||
player.setArmsHeld(held + finalAmount);
|
player.setArmsHeld(held + finalAmount);
|
||||||
|
} else {
|
||||||
|
System.out.println("You don't have that much arms stored in the warehouse!");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
System.out.println("Sorry this transfer cannot be made");
|
System.out.println("Sorry this transfer cannot be made");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
System.out.println("Wait, that's not a valid input please try again");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void showWarehouse() {
|
public void showWarehouse() {
|
||||||
System.out.println("Opium : " + this.wOpium);
|
System.out.println("--------------------\nWarehouse\n--------------------");
|
||||||
System.out.println("Silk : " + this.wSilk);
|
System.out.println("Opium : " + player.getwOpium());
|
||||||
System.out.println("General : " + this.wGeneral);
|
System.out.println("Silk : " + player.getwSilk());
|
||||||
System.out.println("Arms : " + this.wArms);
|
System.out.println("General : " + player.getwGeneral());
|
||||||
|
System.out.println("Arms : " + player.getwArms());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void changeWarehouse() {
|
public void changeWarehouse() {
|
||||||
boolean keepGoing = true;
|
boolean keepGoing = true;
|
||||||
while(keepGoing) {
|
while (keepGoing) {
|
||||||
this.showWarehouse();
|
this.showWarehouse();
|
||||||
String input = " ";
|
String input = " ";
|
||||||
System.out.println("Would you like to add(A) or remove(R) resources? ");
|
System.out.println("Would you like to add(A) or remove(R) resources? ");
|
||||||
Scanner keyboard = new Scanner(System.in);
|
Scanner keyboard = new Scanner(System.in);
|
||||||
input = keyboard.next();
|
input = keyboard.next();
|
||||||
if(input.equalsIgnoreCase("R")) {
|
if (input.equalsIgnoreCase("R")) {
|
||||||
this.removeAmount();
|
this.removeAmount();
|
||||||
this.showWarehouse();
|
this.showWarehouse();
|
||||||
}
|
} else if (input.equalsIgnoreCase("A")) {
|
||||||
else if(input.equalsIgnoreCase("A")) {
|
|
||||||
this.addAmount();
|
this.addAmount();
|
||||||
this.showWarehouse();
|
this.showWarehouse();
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.out.println("Don't waste the warehouse's time, try again later with a valid input");
|
||||||
}
|
}
|
||||||
|
|
||||||
String check;
|
String check;
|
||||||
System.out.println("Would you like to do any other business? Y / N?");
|
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")) {
|
if (check.equalsIgnoreCase("Y")) {
|
||||||
keepGoing = true;
|
keepGoing = true;
|
||||||
}
|
} else if (check.equalsIgnoreCase("N")) {
|
||||||
else if(check.equalsIgnoreCase("N")) {
|
|
||||||
keepGoing = false;
|
keepGoing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,15 @@ public class loanShark {
|
|||||||
player.setDebt(player.getDebt() + loanAsk);
|
player.setDebt(player.getDebt() + loanAsk);
|
||||||
player.setMoney(player.getMoney() + loanAsk);
|
player.setMoney(player.getMoney() + loanAsk);
|
||||||
}
|
}
|
||||||
|
//updated
|
||||||
|
else{
|
||||||
|
System.out.println("Sorry you can't be loaned that much");
|
||||||
|
break;
|
||||||
|
}
|
||||||
String check;
|
String check;
|
||||||
System.out.println("Would you like to do any other business? Y / N?");
|
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")) {
|
if(check.equalsIgnoreCase("Y")) {
|
||||||
keepGoing = true;
|
keepGoing = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user