Merge remote-tracking branch 'origin/master'

# Conflicts:
#	.idea/workspace.xml
#	src/ShipWarfare.java
This commit is contained in:
Vikram
2019-02-25 07:40:36 -07:00
7 changed files with 253 additions and 160 deletions

2
.idea/misc.xml generated
View File

@@ -3,7 +3,7 @@
<component name="ProjectKey">
<option name="state" value="project://63537948-39a4-48a0-9c97-34259a0fa913" />
</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" />
</component>
<component name="SvnBranchConfigurationManager">

8
README.md Normal file
View 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.

View File

@@ -29,6 +29,7 @@ public class Bank{
if(response.equalsIgnoreCase("W")){
boolean notDone2 = true;
while(notDone2){
System.out.println("How much do you wish to Withdraw?");
int withdraw = input.nextInt();
if(withdraw <= player.getBank()){
player.setMoney(withdraw + player.getMoney());
@@ -40,6 +41,7 @@ public class Bank{
}else if(response.equalsIgnoreCase("D")){
boolean notDone2 = true;
while(notDone2){
System.out.println("How much do you wish to Deposit?");
int deposit = input.nextInt();
if(deposit <= player.getMoney()){
player.setBank(deposit + player.getBank());
@@ -54,6 +56,7 @@ public class Bank{
while(notDone3){
System.out.println("Would you like to continue? Y/N");
response = input.nextLine();
response = input.nextLine();
if(response.equalsIgnoreCase("Y")){
notDone3 = false;
}else if(response.equalsIgnoreCase("N")){

View File

@@ -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");

View File

@@ -1,170 +1,205 @@
import java.util.Scanner;
public class Warehouse {
private int wOpium = 25;
private int wSilk = 0;
private int wGeneral = 0;
private int wArms = 0;
private Player player;
/*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 void setPlayer(Player player) {
Player playerDumy = new Player(player);
this.player = playerDumy;
}
public Player getPlayer(){
Player playerDummy = new Player(player);
return playerDummy;
}
public Player getPlayer() {
Player playerDummy = new Player(player);
return playerDummy;
}
public Warehouse(Player player){
Player playerDummy = new Player(player);
this.player = playerDummy;
}
public Warehouse(Player player) {
Player playerDummy = new Player(player);
this.player = playerDummy;
}
public void addAmount() {
int amount = 0;
int finalAmount = 0;
System.out.println("Please enter the amount of the good you would like to ADD.");
Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextInt();
if(amount <= player.getOpiumHeld()) {
finalAmount = amount;
}
else if(amount <= player.getSilkHeld()) {
finalAmount = amount;
}
else if(amount <= player.getGeneralHeld()) {
finalAmount = amount;
}
else if(amount <= player.getArmsHeld()) {
finalAmount = amount;
}
String good;
System.out.println("Please enter a good to transfer O, S, G, A :");
good = keyboard.nextLine();
int held = 0;
if (amount > 0) {
if (good.equalsIgnoreCase("O")) {
this.wOpium += finalAmount;
held = player.getOpiumHeld();
player.setOpiumHeld(held - finalAmount);
System.out.println(player.getOpiumHeld());
}
else if(good.equalsIgnoreCase("S")) {
this.wSilk += finalAmount;
held = player.getSilkHeld();
player.setSilkHeld(held - finalAmount);
}
else if(good.equalsIgnoreCase("G")) {
this.wGeneral += finalAmount;
held = player.getGeneralHeld();
player.setGeneralHeld(held - finalAmount);
}
else if(good.equalsIgnoreCase("A")) {
this.wArms += finalAmount;
held = player.getArmsHeld();
player.setArmsHeld(held - finalAmount);
}
}
else {
System.out.println("Sorry this transfer cannot be made");
}
}
public void removeAmount() {
int amount = 0;
int finalAmount = 0;
System.out.println("Please enter the amount of the good you would like to REMOVE");
Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextInt();
if(amount <= this.wOpium) {
finalAmount = amount;
}
else if(amount <= this.wSilk) {
finalAmount = amount;
}
else if(amount <= this.wGeneral) {
finalAmount = amount;
}
else if(amount <= this.wArms) {
finalAmount = amount;
}
public void addAmount() {
boolean askGood = false;
String amount;
int finalAmount = 0;
System.out.println("Please enter the amount of the good you would like to ADD.");
Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextLine();
try {
if (Integer.parseInt(amount) <= player.getOpiumHeld() || Integer.parseInt(amount) <= player.getSilkHeld() || Integer.parseInt(amount) <= player.getGeneralHeld() || Integer.parseInt(amount) <= player.getArmsHeld()) {
finalAmount = Integer.parseInt(amount);
askGood = true;
} else {
System.out.println("Nice try but you don't have any items of that quantity!");
askGood = false;
}
if (askGood == true) {
String good;
System.out.println("Please enter a good to transfer O, S, G, A :");
good = keyboard.nextLine();
int held = 0;
if (Integer.parseInt(amount) > 0) {
if (good.equalsIgnoreCase("O")) {
if (player.getOpiumHeld() >= Integer.parseInt(amount)) {
player.setwOpium(player.getwOpium() + finalAmount);
held = player.getOpiumHeld();
player.setOpiumHeld(held - finalAmount);
System.out.println(player.getOpiumHeld());
} else {
System.out.println("You don't even have that much opium!");
}
} else if (good.equalsIgnoreCase("S")) {
if (player.getSilkHeld() >= Integer.parseInt(amount)) {
player.setwSilk(player.getwSilk() + finalAmount);
held = player.getSilkHeld();
player.setSilkHeld(held - finalAmount);
} else {
System.out.println("You don't even have that much silk!");
}
} else if (good.equalsIgnoreCase("G")) {
if (player.getGeneralHeld() >= Integer.parseInt(amount)) {
player.setwGeneral(player.getwGeneral() + finalAmount);
held = player.getGeneralHeld();
player.setGeneralHeld(held - finalAmount);
} else {
System.out.println("You don't even have that much general cargo!");
}
} else if (good.equalsIgnoreCase("A")) {
if (player.getArmsHeld() >= Integer.parseInt(amount)) {
player.setwArms(player.getwArms() + finalAmount);
held = player.getArmsHeld();
player.setArmsHeld(held - finalAmount);
} else {
System.out.println("You don't even have that much Arms!");
}
}
} else {
System.out.println("Sorry this transfer cannot be made");
}
}
} catch (Exception e) {
System.out.println("Wait, that's not a valid input please try again");
}
}
public void removeAmount() {
String amount;
boolean askGood = false;
int finalAmount = 0;
System.out.println("Please enter the amount of the good you would like to REMOVE");
Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextLine();
try {
if (Integer.parseInt(amount) <= player.getwOpium() || Integer.parseInt(amount) <= player.getwSilk() || Integer.parseInt(amount) <= player.getwGeneral() || Integer.parseInt(amount) <= player.getwArms()) {
finalAmount = Integer.parseInt(amount);
askGood = true;
} else {
System.out.println("Nice try but you don't have any items of that quantity in the warehouse!");
askGood = false;
}
if (askGood == true) {
String good;
System.out.println("Please enter a good to transfer O, S, G, A :");
good = keyboard.nextLine();
int held = 0;
if (Integer.parseInt(amount) > 0) {
if (good.equalsIgnoreCase("O")) {
if (player.getwOpium() >= Integer.parseInt(amount)) {
player.setwOpium(player.getwOpium() - Integer.parseInt(amount));
held = player.getOpiumHeld();
player.setOpiumHeld(held + finalAmount);
} else {
System.out.println("You don't have that much opium stored in the warehouse!");
}
} else if (good.equalsIgnoreCase("S")) {
if (player.getwSilk() >= Integer.parseInt(amount)) {
player.setwSilk(player.getwSilk() - Integer.parseInt(amount));
held = player.getSilkHeld();
player.setSilkHeld(held + finalAmount);
} else {
System.out.println("You don't have that much silk stored in the warehouse!");
}
} else if (good.equalsIgnoreCase("G")) {
if (player.getwGeneral() >= Integer.parseInt(amount)) {
player.setwGeneral(player.getwGeneral() - Integer.parseInt(amount));
held = player.getGeneralHeld();
player.setGeneralHeld(held + finalAmount);
} else {
System.out.println("You don't have that much general cargo stored in the warehouse!");
}
} else if (good.equalsIgnoreCase("A")) {
if (player.getwArms() >= Integer.parseInt(amount)) {
player.setwArms(player.getwArms() - Integer.parseInt(amount));
held = player.getArmsHeld();
player.setArmsHeld(held + finalAmount);
} else {
System.out.println("You don't have that much arms stored in the warehouse!");
}
}
} else {
System.out.println("Sorry this transfer cannot be made");
}
}
}catch (Exception e){
System.out.println("Wait, that's not a valid input please try again");
}
}
String good;
System.out.println("Please enter a good to transfer O, S, G, A :");
good = keyboard.nextLine();
int held = 0;
if (amount > 0) {
if (good.equalsIgnoreCase("O")) {
this.wOpium -= amount;
held = player.getOpiumHeld();
player.setOpiumHeld(held + finalAmount);
}
else if(good.equalsIgnoreCase("S")) {
this.wSilk -= amount;
held = player.getSilkHeld();
player.setSilkHeld(held + finalAmount);
}
else if(good.equalsIgnoreCase("G")) {
this.wGeneral -= amount;
held = player.getGeneralHeld();
player.setGeneralHeld(held + finalAmount);
}
else if(good.equalsIgnoreCase("A")) {
this.wArms -= amount;
held = player.getArmsHeld();
player.setArmsHeld(held + finalAmount);
}
}
else {
System.out.println("Sorry this transfer cannot be made");
}
}
public void showWarehouse() {
System.out.println("--------------------\nWarehouse\n--------------------");
System.out.println("Opium : " + player.getwOpium());
System.out.println("Silk : " + player.getwSilk());
System.out.println("General : " + player.getwGeneral());
System.out.println("Arms : " + player.getwArms());
}
public void changeWarehouse() {
boolean keepGoing = true;
while (keepGoing) {
this.showWarehouse();
String input = " ";
System.out.println("Would you like to add(A) or remove(R) resources? ");
Scanner keyboard = new Scanner(System.in);
input = keyboard.next();
if (input.equalsIgnoreCase("R")) {
this.removeAmount();
this.showWarehouse();
} else if (input.equalsIgnoreCase("A")) {
this.addAmount();
this.showWarehouse();
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);
}
}
else{
System.out.println("Don't waste the warehouse's time, try again later with a valid input");
}
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?");
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;
}
}
}
if (check.equalsIgnoreCase("Y")) {
keepGoing = true;
} else if (check.equalsIgnoreCase("N")) {
keepGoing = false;
}
}
}
public static void main(String[] args){
public static void main(String[] args) {
}
}

View File

@@ -28,9 +28,15 @@ public class loanShark {
player.setDebt(player.getDebt() + loanAsk);
player.setMoney(player.getMoney() + loanAsk);
}
//updated
else{
System.out.println("Sorry you can't be loaned that much");
break;
}
String check;
System.out.println("Would you like to do any other business? Y / N?");
check = keyboard.nextLine();
check = keyboard.nextLine();
if(check.equalsIgnoreCase("Y")) {
keepGoing = true;