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">
|
||||
<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
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")){
|
||||
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")){
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -1,170 +1,205 @@
|
||||
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;
|
||||
private int wArms = 0;*/
|
||||
private Player player;
|
||||
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
Player playerDumy = new Player(player);
|
||||
this.player= playerDumy;
|
||||
this.player = playerDumy;
|
||||
}
|
||||
|
||||
public Player getPlayer(){
|
||||
public Player getPlayer() {
|
||||
Player playerDummy = new Player(player);
|
||||
return playerDummy;
|
||||
}
|
||||
|
||||
public Warehouse(Player player){
|
||||
public Warehouse(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
else if(amount <= player.getSilkHeld()) {
|
||||
finalAmount = amount;
|
||||
}
|
||||
else if(amount <= player.getGeneralHeld()) {
|
||||
finalAmount = amount;
|
||||
}
|
||||
else if(amount <= player.getArmsHeld()) {
|
||||
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;
|
||||
}
|
||||
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 (amount > 0) {
|
||||
if (Integer.parseInt(amount) > 0) {
|
||||
if (good.equalsIgnoreCase("O")) {
|
||||
this.wOpium += finalAmount;
|
||||
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")) {
|
||||
this.wSilk += finalAmount;
|
||||
} 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")) {
|
||||
this.wGeneral += finalAmount;
|
||||
} 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")) {
|
||||
this.wArms += finalAmount;
|
||||
} 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 {
|
||||
} 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;
|
||||
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.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;
|
||||
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 (amount > 0) {
|
||||
if (Integer.parseInt(amount) > 0) {
|
||||
if (good.equalsIgnoreCase("O")) {
|
||||
this.wOpium -= 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")) {
|
||||
this.wSilk -= amount;
|
||||
} 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")) {
|
||||
this.wGeneral -= amount;
|
||||
} 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")) {
|
||||
this.wArms -= amount;
|
||||
} 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 {
|
||||
} 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 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);
|
||||
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) {
|
||||
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")) {
|
||||
if (input.equalsIgnoreCase("R")) {
|
||||
this.removeAmount();
|
||||
this.showWarehouse();
|
||||
}
|
||||
else if(input.equalsIgnoreCase("A")) {
|
||||
} 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;
|
||||
System.out.println("Would you like to do any other business? Y / N?");
|
||||
check = keyboard.nextLine();
|
||||
check = keyboard.nextLine();
|
||||
|
||||
if(check.equalsIgnoreCase("Y")) {
|
||||
if (check.equalsIgnoreCase("Y")) {
|
||||
keepGoing = true;
|
||||
}
|
||||
else if(check.equalsIgnoreCase("N")) {
|
||||
} else if (check.equalsIgnoreCase("N")) {
|
||||
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.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;
|
||||
|
||||
Reference in New Issue
Block a user