Compare commits
138 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c24d485463 | |||
| ae39a210be | |||
| 36f72b22e4 | |||
| 4efe650091 | |||
|
|
e341112aec | ||
|
|
a56a6690ee | ||
|
|
c179ac17ae | ||
| 29e0f3e683 | |||
| 923ff50c87 | |||
|
|
15525d789e | ||
|
|
e0171bacfa | ||
|
|
8c776b769b | ||
| 428a7caf80 | |||
|
|
af81624e27 | ||
|
|
762b399c4b | ||
|
|
8402a2368c | ||
|
|
8c3098a498 | ||
|
|
f1a43a279a | ||
|
|
140e8dc706 | ||
|
|
e21a7c9f54 | ||
|
|
023e77f034 | ||
|
|
696af67665 | ||
| cf0fd1281f | |||
|
|
4e4d30c222 | ||
|
|
d2e42048b2 | ||
|
|
303be2eea6 | ||
|
|
963f16afca | ||
|
|
fd03a7c588 | ||
|
|
c912394dd9 | ||
| c0914d8e5e | |||
| 11b16b4e40 | |||
| 076ba12ef1 | |||
| 59de84a47d | |||
| e1671d8d21 | |||
| e6a67ce1e4 | |||
|
|
1ac82edf1e | ||
|
|
1df0cbec36 | ||
|
|
0af20d9f67 | ||
|
|
5b8682a900 | ||
| a58d0fa184 | |||
|
|
4d09891665 | ||
| 91bb72351e | |||
|
|
ba16ea1809 | ||
|
|
9b9af573a8 | ||
|
|
c6df980f8e | ||
|
|
666e409e74 | ||
|
|
89f9e47921 | ||
| 414a9634b5 | |||
| f4fbc474e7 | |||
|
|
4c8b99d4bb | ||
|
|
ffb77b14a0 | ||
|
|
0c5317cf6f | ||
|
|
461171ff46 | ||
|
|
13f30b681a | ||
|
|
1d5e5aa706 | ||
|
|
01ee9b2600 | ||
| 3aa6ad619d | |||
| 0b8b8ed50c | |||
|
|
df372522e4 | ||
|
|
4fd40af606 | ||
|
|
664d194d7b | ||
|
|
2198fffbd5 | ||
| d395d91730 | |||
| 31e93f6997 | |||
| 0f2e8848ad | |||
| c3f7cc16d2 | |||
| 9a15f6bc63 | |||
|
|
680225550f | ||
|
|
6778aa5737 | ||
|
|
46624389f5 | ||
| a0e0ab517d | |||
|
|
5e33374e3c | ||
| 325c4127dd | |||
|
|
fde76a5bfb | ||
|
|
888d8a1c92 | ||
|
|
42c4534f52 | ||
|
|
a07d633ff9 | ||
|
|
b4e0e18d20 | ||
|
|
d558e7cf0c | ||
|
|
36aa789590 | ||
|
|
e5807a46af | ||
|
|
5f6abbc817 | ||
| b376ad5284 | |||
| b945cafe98 | |||
| 75673d40e1 | |||
|
|
9feac6e90e | ||
|
|
1bb00d0d01 | ||
|
|
80102eabee | ||
|
|
f5845cb8df | ||
|
|
5a7d1e7c34 | ||
|
|
370b3ee041 | ||
|
|
7314bc174f | ||
|
|
5c78f561d8 | ||
|
|
271a37877b | ||
|
|
89188152e6 | ||
| 6b9e3dcc06 | |||
| 14e5eb2d30 | |||
| bf2d1c3fb0 | |||
|
|
b62274cda3 | ||
|
|
72708e53f2 | ||
|
|
540605f0f1 | ||
|
|
f6fa9dc646 | ||
| 93f16751f1 | |||
| 507fe4debd | |||
| 2d1864bb87 | |||
|
|
de3c686db7 | ||
|
|
2abef09de8 | ||
|
|
b1421e19d4 | ||
|
|
55e1ae2d5f | ||
|
|
697c221323 | ||
|
|
4aaff2809a | ||
|
|
581bee7bfe | ||
|
|
1295d625fb | ||
|
|
52ec4c2422 | ||
|
|
27ac100618 | ||
|
|
94762234af | ||
|
|
207d258e05 | ||
|
|
f236650611 | ||
|
|
757d258e3d | ||
|
|
e7a0ddf085 | ||
|
|
70b698c22e | ||
|
|
4cc9ac5d26 | ||
|
|
c66e3d5d70 | ||
|
|
40ba6b0c9b | ||
|
|
2ae60073c0 | ||
|
|
c4c4a41776 | ||
|
|
6b379bae3a | ||
|
|
67ddc34c65 | ||
|
|
b6b5c14c56 | ||
|
|
d1c3fe0f7e | ||
|
|
fcb0b50468 | ||
|
|
237ce1da27 | ||
|
|
3b068d869b | ||
|
|
70d9a36af5 | ||
|
|
06739ed20c | ||
|
|
8d35d073e4 | ||
|
|
672707f5b6 | ||
|
|
83057e863f |
8
.idea/misc.xml
generated
8
.idea/misc.xml
generated
@@ -1,9 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavadocGenerationManager">
|
||||
<option name="OUTPUT_DIRECTORY" value="$USER_HOME$/Desktop/Javadocs TaipanClone" />
|
||||
<option name="OPTION_HIERARCHY" value="false" />
|
||||
<option name="OPTION_NAVIGATOR" value="false" />
|
||||
<option name="OPTION_INDEX" value="false" />
|
||||
</component>
|
||||
<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_201" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="SvnBranchConfigurationManager">
|
||||
|
||||
818
.idea/workspace.xml
generated
818
.idea/workspace.xml
generated
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,35 +1,62 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Bank{
|
||||
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* setter method that takes in a Player object as an argument.
|
||||
*
|
||||
* @param player object of the class Player
|
||||
*/
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for obtaining a player object.
|
||||
*
|
||||
* @return returns player object
|
||||
*/
|
||||
|
||||
public Player getPlayer(){
|
||||
Player playerDummy = new Player(player);
|
||||
return playerDummy;
|
||||
}
|
||||
/**
|
||||
* Class Constructor that takes in a type player as a parameter
|
||||
*
|
||||
* @param player object of the class Player
|
||||
*/
|
||||
|
||||
public Bank(Player player){
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to withdraw or deposit money into the bank account
|
||||
* by prompting the user if they would like to withdraw or deposit. Followed
|
||||
* by prompting them to enter an amount to transfer. This method also uses the
|
||||
* player class to see if the transfer can be made,and if it can it changes the
|
||||
* values accordingly
|
||||
*/
|
||||
public void bank(){
|
||||
Scanner input = new Scanner(System.in);
|
||||
boolean notDone = true;
|
||||
int check = 0;
|
||||
while(notDone){
|
||||
//Prompt the user if they want to withdraw or deposit
|
||||
System.out.println("Would you like to Withdraw or Deposit?");
|
||||
String response = input.nextLine();
|
||||
//If user chose withdraw then subtract the amount from bank account and add it to cash
|
||||
if(response.equalsIgnoreCase("W")){
|
||||
boolean notDone2 = true;
|
||||
while(notDone2){
|
||||
System.out.println("How much do you wish to Withdraw?");
|
||||
int withdraw = input.nextInt();
|
||||
//Prompt the user for the amount and check if the bank has sufficient funds
|
||||
if(withdraw <= player.getBank()){
|
||||
player.setMoney(withdraw + player.getMoney());
|
||||
player.setBank(player.getBank()-withdraw);
|
||||
@@ -37,9 +64,13 @@ public class Bank{
|
||||
check = 1;
|
||||
}
|
||||
}
|
||||
}else if(response.equalsIgnoreCase("D")){
|
||||
|
||||
}
|
||||
//If the user chooses to deposit the continue to this code
|
||||
else if(response.equalsIgnoreCase("D")){
|
||||
boolean notDone2 = true;
|
||||
while(notDone2){
|
||||
//Prompt the user for the amount they would like to deposit and ensure suffiecent funds
|
||||
System.out.println("How much do you wish to Deposit?");
|
||||
int deposit = input.nextInt();
|
||||
if(deposit <= player.getMoney()){
|
||||
@@ -52,6 +83,7 @@ public class Bank{
|
||||
}
|
||||
if(check == 1){
|
||||
boolean notDone3 = true;
|
||||
// Asks user if they would like to continue in bank or not
|
||||
while(notDone3){
|
||||
System.out.println("Would you like to continue? Y/N");
|
||||
response = input.nextLine();
|
||||
|
||||
249
src/Player.java
249
src/Player.java
@@ -1,3 +1,5 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Player {
|
||||
|
||||
private String name = "Taipan";
|
||||
@@ -16,11 +18,17 @@ public class Player {
|
||||
private int wGeneral = 0;
|
||||
private int wArms = 0;
|
||||
private boolean retire = false;
|
||||
private int cargoSpace = 60;
|
||||
|
||||
public Player(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
*
|
||||
* @param player object of the class Player
|
||||
*/
|
||||
public Player(Player player){
|
||||
this.bank = player.bank;
|
||||
this.money = player.money;
|
||||
@@ -36,128 +44,307 @@ public class Player {
|
||||
this.wSilk = player.wSilk;
|
||||
this.wGeneral = player.wGeneral;
|
||||
this.wArms = player.wArms;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for the instance variable cargoSpace.
|
||||
*
|
||||
* @return returns the instance variable cargoSpace
|
||||
*/
|
||||
|
||||
public int getCargoSpace() {
|
||||
return cargoSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable cargoSpace.
|
||||
*
|
||||
* @param cargoSpace takes an int that is greater than 0 as an argument
|
||||
*/
|
||||
|
||||
public void setCargoSpace(int cargoSpace) {
|
||||
if(cargoSpace > 0){
|
||||
this.cargoSpace = cargoSpace;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for the instance variable retire.
|
||||
*
|
||||
* @return returns the instance variable retire
|
||||
*/
|
||||
|
||||
public boolean getRetire(){
|
||||
return retire;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable retire.
|
||||
*
|
||||
* @param retire takes a boolean as an argument
|
||||
*/
|
||||
|
||||
public void setRetire(boolean retire){
|
||||
if(retire){
|
||||
this.retire = retire;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for the instance variable name.
|
||||
*
|
||||
* @return returns the instance variable name
|
||||
*/
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable name.
|
||||
*
|
||||
* @param name takes a string as an argument
|
||||
*/
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for the instance variable HP.
|
||||
*
|
||||
* @return returns the instance variable HP
|
||||
*/
|
||||
|
||||
public int getHP() {
|
||||
return HP;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable HP.
|
||||
*
|
||||
* @param HP takes an int as an argument
|
||||
*/
|
||||
|
||||
public void setHP(int HP) {
|
||||
|
||||
this.HP = HP;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for the instance variable bank.
|
||||
*
|
||||
* @return returns the instance variable bank
|
||||
*/
|
||||
|
||||
public int getBank() {
|
||||
return bank;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable bank.
|
||||
*
|
||||
* @param bank takes an int that is greater than or equal to 0 as an argument
|
||||
*/
|
||||
|
||||
public void setBank(int bank) {
|
||||
if (bank >= 0) {
|
||||
this.bank = bank;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for the instance variable money.
|
||||
*
|
||||
* @return returns the instance variable money
|
||||
*/
|
||||
|
||||
public int getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable money.
|
||||
*
|
||||
* @param money takes an int that is greater than or equal to 0 as an argument
|
||||
*/
|
||||
|
||||
public void setMoney(int money) {
|
||||
if (money >= 0) {
|
||||
this.money = money;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for the instance variable opiumHeld.
|
||||
*
|
||||
* @return returns the instance variable opiumHeld
|
||||
*/
|
||||
|
||||
public int getOpiumHeld() {
|
||||
return opiumHeld;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable opiumHeld.
|
||||
*
|
||||
* @param opiumHeld takes an int that is greater than or equal to 0 as an argument
|
||||
*/
|
||||
|
||||
public void setOpiumHeld(int opiumHeld) {
|
||||
if (opiumHeld >= 0) {
|
||||
this.opiumHeld = opiumHeld;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for the instance variable silkHeld.
|
||||
*
|
||||
* @return returns the instance variable silkHeld
|
||||
*/
|
||||
|
||||
public int getSilkHeld() {
|
||||
return silkHeld;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable silkHeld.
|
||||
*
|
||||
* @param silkHeld takes an int that is greater than or equal to 0 as an argument
|
||||
*/
|
||||
|
||||
public void setSilkHeld(int silkHeld) {
|
||||
if (silkHeld >= 0) {
|
||||
this.silkHeld = silkHeld;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for the instance variable generalHeld.
|
||||
*
|
||||
* @return returns the instance variable generalHeld
|
||||
*/
|
||||
|
||||
public int getGeneralHeld() {
|
||||
return generalHeld;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable generalHeld.
|
||||
*
|
||||
* @param generalHeld takes an int that is greater than or equal to 0 as an argument
|
||||
*/
|
||||
|
||||
public void setGeneralHeld(int generalHeld) {
|
||||
if (generalHeld >= 0) {
|
||||
this.generalHeld = generalHeld;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for the instance variable armsHeld.
|
||||
*
|
||||
* @return returns the instance variable armsHeld
|
||||
*/
|
||||
|
||||
public int getArmsHeld() {
|
||||
return armsHeld;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable armsHeld.
|
||||
*
|
||||
* @param armsHeld takes an int that is greater than or equal to 0 as an argument
|
||||
*/
|
||||
|
||||
public void setArmsHeld(int armsHeld) {
|
||||
if (armsHeld >= 0) {
|
||||
this.armsHeld = armsHeld;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for the instance variable location.
|
||||
*
|
||||
* @return returns the instance variable location
|
||||
*/
|
||||
|
||||
public int getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable location.
|
||||
*
|
||||
* @param location takes an int that is greater than or equal to 0 as an argument
|
||||
*/
|
||||
|
||||
public void setLocation(int location) {
|
||||
if (location >= 0) {
|
||||
this.location = location;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for the instance variable guns.
|
||||
*
|
||||
* @return returns the instance variable guns
|
||||
*/
|
||||
|
||||
public int getGuns() {
|
||||
return guns;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable guns.
|
||||
*
|
||||
* @param guns takes an int that is greater than or equal to 0 as an argument
|
||||
*/
|
||||
|
||||
public void setGuns(int guns) {
|
||||
if (guns >= 0) {
|
||||
this.guns = guns;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for the instance variable debt.
|
||||
*
|
||||
* @return returns the instance variable debt
|
||||
*/
|
||||
|
||||
public int getDebt() {
|
||||
return debt;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable debt.
|
||||
*
|
||||
* @param debt takes an int that is greater than or equal to 0 as an argument
|
||||
*/
|
||||
|
||||
public void setDebt(int debt) {
|
||||
if (debt >= 0) {
|
||||
this.debt = debt;
|
||||
}
|
||||
}
|
||||
|
||||
public int getwOpium(){ return wOpium; }
|
||||
/**
|
||||
* getter method for the instance variable wOpium.
|
||||
*
|
||||
* @return returns the instance variable wOpium
|
||||
*/
|
||||
|
||||
public int getwOpium() {
|
||||
return wOpium;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable wOpium.
|
||||
*
|
||||
* @param wOpium takes an int that is greater than or equal to 0 as an argument
|
||||
*/
|
||||
|
||||
public void setwOpium(int wOpium) {
|
||||
if (wOpium >= 0){
|
||||
@@ -165,7 +352,21 @@ public class Player {
|
||||
}
|
||||
}
|
||||
|
||||
public int getwSilk(){return wSilk;}
|
||||
/**
|
||||
* getter method for the instance variable wSilk.
|
||||
*
|
||||
* @return returns the instance variable wSilk
|
||||
*/
|
||||
|
||||
public int getwSilk() {
|
||||
return wSilk;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable wSilk.
|
||||
*
|
||||
* @param wSilk takes an int that is greater than or equal to 0 as an argument
|
||||
*/
|
||||
|
||||
public void setwSilk(int wSilk) {
|
||||
if (wSilk >= 0){
|
||||
@@ -173,7 +374,21 @@ public class Player {
|
||||
}
|
||||
}
|
||||
|
||||
public int getwGeneral(){return wGeneral;}
|
||||
/**
|
||||
* getter method for the instance variable wGeneral.
|
||||
*
|
||||
* @return returns the instance variable wGeneral
|
||||
*/
|
||||
|
||||
public int getwGeneral() {
|
||||
return wGeneral;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable wGeneral.
|
||||
*
|
||||
* @param wGeneral takes an int that is greater than or equal to 0 as an argument
|
||||
*/
|
||||
|
||||
public void setwGeneral(int wGeneral) {
|
||||
if (wGeneral >= 0){
|
||||
@@ -181,7 +396,21 @@ public class Player {
|
||||
}
|
||||
}
|
||||
|
||||
public int getwArms(){return wArms;}
|
||||
/**
|
||||
* getter method for the instance variable wArms.
|
||||
*
|
||||
* @return returns the instance variable wArms
|
||||
*/
|
||||
|
||||
public int getwArms() {
|
||||
return wArms;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for the instance variable wArms.
|
||||
*
|
||||
* @param wArms takes an int that is greater than or equal to 0 as an argument
|
||||
*/
|
||||
|
||||
public void setwArms(int wArms) {
|
||||
if (wArms >= 0){
|
||||
@@ -189,9 +418,15 @@ public class Player {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to indicate that you have lost the game. If the player has lost, console will be cleared and will only
|
||||
* show the statement "Game Over". After showing the message the game closes.
|
||||
*
|
||||
**/
|
||||
|
||||
public void gameOver(){
|
||||
System.out.flush();
|
||||
System.out.println("Game over");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import java.util.Scanner;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
public class ShipWarfare {
|
||||
|
||||
private int numOfPeasantShips = 0;
|
||||
@@ -13,22 +14,37 @@ public class ShipWarfare {
|
||||
private String pirateName = "Liu Yen";
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Class Constructor that takes in a type player as a parameter
|
||||
* @param player object of the class Player
|
||||
*/
|
||||
public ShipWarfare(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for player
|
||||
* @param player object of the class Player
|
||||
*/
|
||||
public void setPlayer(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for obtaining a player object.
|
||||
* @return returns player object
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
Player playerDummy = new Player(player);
|
||||
return playerDummy;
|
||||
}
|
||||
|
||||
//This fleet is easy to defeat as a maximum of 15 ships can run away each volley, they can not tank hits
|
||||
/**
|
||||
* This fleet is easy to defeat as a maximum of 15 ships can run away each volley, they can not tank hits
|
||||
* @throws Exception in case of errors due to the delay
|
||||
*/
|
||||
public void peasantFleetAttack() throws Exception {
|
||||
Scanner userResponse = new Scanner(System.in);
|
||||
setNumOfPeasantShips(numOfShips());
|
||||
@@ -41,6 +57,7 @@ public class ShipWarfare {
|
||||
if (response.equalsIgnoreCase("f")) {
|
||||
userAttacks = true;
|
||||
System.out.println("Ohh, fight ehh?");
|
||||
delayForSeconds(1);
|
||||
boolean winOrLose = destroyPeasantShipsOrEscape();
|
||||
if (winOrLose == true) {
|
||||
break;
|
||||
@@ -54,6 +71,7 @@ public class ShipWarfare {
|
||||
break;
|
||||
} else {
|
||||
System.out.println("Phew! Got away safely");
|
||||
delayForSeconds(2);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -63,7 +81,11 @@ public class ShipWarfare {
|
||||
|
||||
|
||||
}
|
||||
//This fleet is difficult to defeat as a maximum of 10 ships can run away each volley, they can tank hits
|
||||
|
||||
/**
|
||||
* This fleet is difficult to defeat as a maximum of 10 ships can run away each volley, they can tank hits
|
||||
* @throws Exception in case of errors due to the delay
|
||||
*/
|
||||
public void littyFleetAttack() throws Exception {
|
||||
Scanner userResponse = new Scanner(System.in);
|
||||
setNumOfLittyShips(numOfShips());
|
||||
@@ -83,10 +105,12 @@ public class ShipWarfare {
|
||||
} else if (response.equalsIgnoreCase("r")) {
|
||||
if (runFromShips() == false) {
|
||||
System.out.println("Couldn't run away!");
|
||||
delayForSeconds(1);
|
||||
if (destroyLittyShipsOrEscape())
|
||||
break;
|
||||
} else {
|
||||
System.out.println("Phew! Got away safely");
|
||||
delayForSeconds(2);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -97,34 +121,49 @@ public class ShipWarfare {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks user if they would like to fight or run against ships
|
||||
*/
|
||||
|
||||
public void fightOrRunMessage() {
|
||||
System.out.printf("What do you want to do? Enter \"f\" to fight, and \"r\" to run (we have %d guns)", player.getGuns());
|
||||
|
||||
}
|
||||
|
||||
public int numOfPeasantShips() {
|
||||
return numOfPeasantShips;
|
||||
System.out.printf("What do you want to do? Enter \"f\" to fight, and \"r\" to run (we have %d guns)\n", player.getGuns());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method that takes in an integer as an argument
|
||||
* @param numOfLittyShips the number of ships to be used in the litty fleet attack
|
||||
*/
|
||||
public void setNumOfLittyShips(int numOfLittyShips) {
|
||||
this.numOfLittyShips = numOfLittyShips;
|
||||
startingLittyShips = numOfLittyShips;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method that takes in an integer as an argument
|
||||
* @param numOfPeasantShips the number of ships to be used in the peasant fleet attack
|
||||
*/
|
||||
|
||||
public void setNumOfPeasantShips(int numOfPeasantShips) {
|
||||
this.numOfPeasantShips = numOfPeasantShips;
|
||||
startingPeasantShips = numOfPeasantShips;
|
||||
|
||||
}
|
||||
|
||||
public void delayForASecond() throws Exception {
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
/**
|
||||
* delays for a specific amount of seconds, takes an integer as an argument
|
||||
* @param num the seconds to delay
|
||||
* @throws Exception in case of errors due to the delay
|
||||
*/
|
||||
public void delayForSeconds(int num) throws Exception {
|
||||
TimeUnit.SECONDS.sleep(num);
|
||||
}
|
||||
|
||||
//The number of ships which attack is based on the amount of money one has on hand
|
||||
/**
|
||||
* The number of ships that attack is based on the amount of money one has on hand
|
||||
* @return the number of ships which will attack
|
||||
*/
|
||||
public int numOfShips() {
|
||||
|
||||
int numOfShipsAttacking = 0;
|
||||
@@ -148,7 +187,11 @@ public class ShipWarfare {
|
||||
|
||||
}
|
||||
|
||||
//One in two chance of running away
|
||||
/**
|
||||
* One in two chance of running away
|
||||
* @return true if the user is allowed to run, false if not, the "default" is false
|
||||
*/
|
||||
|
||||
public boolean runFromShips() {
|
||||
userAttacks = false;
|
||||
Random randomValue = new Random();
|
||||
@@ -161,7 +204,12 @@ public class ShipWarfare {
|
||||
return false;
|
||||
}
|
||||
|
||||
//The loot for defeating a litty fleet is much higher than that of a peasant one
|
||||
/**
|
||||
* The user faces off against the litty ships and either prevails, dies, or runs away
|
||||
* The loot for defeating a litty fleet is much higher than that of a peasant one
|
||||
* @return true if the user wins, loses, or flees, it returns false otherwise
|
||||
* @throws Exception in case of errors due to the delay
|
||||
*/
|
||||
public boolean destroyLittyShipsOrEscape() throws Exception {
|
||||
int calculateLoot = 0;
|
||||
int chanceOfEnemyRun = 0;
|
||||
@@ -173,6 +221,7 @@ public class ShipWarfare {
|
||||
|
||||
//Player volley
|
||||
while (exitValue == 0) {
|
||||
if (player.getGuns() > 0) {
|
||||
for (int j = 0; j < player.getGuns(); j++) {
|
||||
if (userAttacks == true) {
|
||||
int hitOrMiss = randomValue.nextInt(3) + 1;
|
||||
@@ -183,13 +232,13 @@ public class ShipWarfare {
|
||||
break;
|
||||
}
|
||||
System.out.println("Got eem");
|
||||
delayForASecond();
|
||||
delayForSeconds(1);
|
||||
} else if (hitOrMiss == 2) {
|
||||
System.out.printf("ARRG! We missed %s\n", player.getName());
|
||||
delayForASecond();
|
||||
delayForSeconds(1);
|
||||
} else {
|
||||
System.out.println("Darn! Their fleet tanked our attack");
|
||||
delayForASecond();
|
||||
delayForSeconds(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -197,14 +246,19 @@ public class ShipWarfare {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.out.printf("%s! We don't have any GUNS!!!!\n",player.getName());
|
||||
delayForSeconds(1);
|
||||
}
|
||||
|
||||
|
||||
if (numOfLittyShips <= 0) {
|
||||
exitValue = 1;
|
||||
break;
|
||||
}
|
||||
chanceOfEnemyRun = randomValue.nextInt(2) + 1;
|
||||
if (player.getGuns() > 0) {
|
||||
if (chanceOfEnemyRun == 2) {
|
||||
chanceOfEnemyRun = randomValue.nextInt(2) + 1;
|
||||
howMuchRun = randomValue.nextInt(10) + 1;
|
||||
if (howMuchRun != 0 && howMuchRun < numOfLittyShips) {
|
||||
|
||||
@@ -217,10 +271,11 @@ public class ShipWarfare {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.printf("%d ships remaining\n", numOfLittyShips);
|
||||
System.out.println("Oh no, they are taking the offensive!");
|
||||
delayForASecond();
|
||||
delayForSeconds(1);
|
||||
//Computer volley
|
||||
int takeGunChance = randomValue.nextInt(4) + 1;
|
||||
if (takeGunChance == 1 && player.getGuns() > 0) {
|
||||
@@ -234,7 +289,7 @@ public class ShipWarfare {
|
||||
break;
|
||||
}
|
||||
System.out.printf("EEK, our current ship status is %d%% \n", player.getHP());
|
||||
delayForASecond();
|
||||
delayForSeconds(1);
|
||||
if (userAttacks == false) {
|
||||
userAttacks = true;
|
||||
}
|
||||
@@ -245,8 +300,10 @@ public class ShipWarfare {
|
||||
if (response.equalsIgnoreCase("r")) {
|
||||
if (runFromShips() == false) {
|
||||
System.out.println("Couldn't run away");
|
||||
delayForSeconds(1);
|
||||
} else {
|
||||
exitValue = 3;
|
||||
System.out.println("Phew! Got away safely");
|
||||
delayForSeconds(2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -257,15 +314,19 @@ public class ShipWarfare {
|
||||
|
||||
if (exitValue == 1) {
|
||||
System.out.printf("\nGot eem\nVictory!\nIt appears we have defeated the enemy fleet and made it out at %d%% ship status\n", player.getHP());
|
||||
delayForSeconds(1);
|
||||
calculateLoot = (randomValue.nextInt(startingLittyShips) + startingLittyShips) * 300;
|
||||
player.setMoney(player.getMoney() + calculateLoot);
|
||||
System.out.printf("We got $%,d!\n", calculateLoot);
|
||||
delayForSeconds(2);
|
||||
return true;
|
||||
} else if (exitValue == 2) {
|
||||
player.gameOver();
|
||||
|
||||
return true;
|
||||
} else if (exitValue == 3) {
|
||||
System.out.printf("We made it out at %d%% ship status!\n", player.getHP());
|
||||
delayForSeconds(2);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -273,6 +334,11 @@ public class ShipWarfare {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The user faces off against the peasant ships and either prevails, dies, or runs away
|
||||
* @return true if the user wins, loses, or flees, it returns false otherwise
|
||||
* @throws Exception in case of errors due to the delay
|
||||
*/
|
||||
|
||||
public boolean destroyPeasantShipsOrEscape() throws Exception {
|
||||
int calculateLoot = 0;
|
||||
@@ -285,6 +351,8 @@ public class ShipWarfare {
|
||||
|
||||
//Player volley
|
||||
while (exitValue == 0) {
|
||||
if (player.getGuns() > 0) {
|
||||
|
||||
for (int j = 0; j < player.getGuns(); j++) {
|
||||
if (userAttacks == true) {
|
||||
int hitOrMiss = randomValue.nextInt(2) + 1;
|
||||
@@ -295,10 +363,10 @@ public class ShipWarfare {
|
||||
break;
|
||||
}
|
||||
System.out.println("Got eem");
|
||||
delayForASecond();
|
||||
delayForSeconds(1);
|
||||
} else {
|
||||
System.out.printf("ARRG! We missed %s\n", player.getName());
|
||||
delayForASecond();
|
||||
delayForSeconds(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -306,12 +374,19 @@ public class ShipWarfare {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
System.out.printf("%s! We don't have any GUNS!!!!\n", player.getName());
|
||||
delayForSeconds(1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (numOfPeasantShips <= 0) {
|
||||
exitValue = 1;
|
||||
break;
|
||||
}
|
||||
if (player.getGuns() > 0) {
|
||||
chanceOfEnemyRun = randomValue.nextInt(2) + 1;
|
||||
if (chanceOfEnemyRun == 2) {
|
||||
howMuchRun = randomValue.nextInt(15) + 1;
|
||||
@@ -326,10 +401,12 @@ public class ShipWarfare {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.printf("%d ships remaining\n", numOfPeasantShips);
|
||||
delayForSeconds(1);
|
||||
System.out.println("Oh no, they are taking the offensive!");
|
||||
delayForASecond();
|
||||
delayForSeconds(1);
|
||||
//Computer volley
|
||||
int takeGunChance = randomValue.nextInt(4) + 1;
|
||||
if (takeGunChance == 1 && player.getGuns() > 0) {
|
||||
@@ -343,7 +420,7 @@ public class ShipWarfare {
|
||||
break;
|
||||
}
|
||||
System.out.printf("EEK, our current ship status is %d%% \n", player.getHP());
|
||||
delayForASecond();
|
||||
delayForSeconds(1);
|
||||
if (userAttacks == false) {
|
||||
userAttacks = true;
|
||||
}
|
||||
@@ -366,15 +443,18 @@ public class ShipWarfare {
|
||||
|
||||
if (exitValue == 1) {
|
||||
System.out.printf("\nGot eem\nVictory!\nIt appears we have defeated the enemy fleet and made it out at %d%% ship status\n", player.getHP());
|
||||
delayForSeconds(1);
|
||||
calculateLoot = (randomValue.nextInt(startingPeasantShips) + startingPeasantShips) * 100;
|
||||
player.setMoney(player.getMoney() + calculateLoot);
|
||||
System.out.printf("We got $%,d!", calculateLoot);
|
||||
delayForSeconds(2);
|
||||
return true;
|
||||
} else if (exitValue == 2) {
|
||||
player.gameOver();
|
||||
return true;
|
||||
} else if (exitValue == 3) {
|
||||
System.out.printf("We made it out at %d%% ship status!\n", player.getHP());
|
||||
delayForSeconds(2);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -3,22 +3,42 @@ public class Start
|
||||
{
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* gets the player instance variable. The method returns a copy of the instance variable for encapsulation purposes.
|
||||
*
|
||||
* @return playerDummy -- playerDummy is a copy of the player instance variable.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
Player playerTemp = new Player(player);
|
||||
return playerTemp;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the player instance variable equal to a copy of the parameter -- a copy is used for encapsulation purposes.
|
||||
*
|
||||
* @param player is a Player object that will replace the current instance of the player instance variable.
|
||||
*/
|
||||
public void setPlayer(Player player) {
|
||||
Player playerTemp = new Player(player);
|
||||
this.player = playerTemp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks the user to input the name that they would like to be called in the game
|
||||
*
|
||||
* @param name the name that you would like to be called in the game
|
||||
*/
|
||||
public void setFirm (String name) {
|
||||
if (name.length() <= 22) {
|
||||
player.setName(name);
|
||||
}
|
||||
}
|
||||
public void intialize()
|
||||
|
||||
/**
|
||||
* Initializes the game by asking for your name and if you would like to start with either: 1) money and a debt or
|
||||
* 2) guns and no cash/debt.
|
||||
*/
|
||||
public void initialize()
|
||||
{
|
||||
Scanner userInput = new Scanner(System.in);
|
||||
System.out.println("Taipan, \nWhat will you name your firm:");
|
||||
@@ -42,10 +62,15 @@ public class Start
|
||||
player.setBank(999999999);
|
||||
player.setGuns(999);
|
||||
player.setHP(99999999);
|
||||
player.setCargoSpace(99999999);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param player object of the class Player
|
||||
*/
|
||||
public Start(Player player)
|
||||
{
|
||||
Player playerTemp = new Player(player);
|
||||
|
||||
@@ -3,108 +3,170 @@ import java.util.Scanner;
|
||||
public class TaipanShop {
|
||||
|
||||
private Player player;
|
||||
private int cargoSpace = 60;
|
||||
private int currentCargo = 0;
|
||||
private int opiumPrice = 16000;
|
||||
private int silkPrice = 1600;
|
||||
private int armsPrice = 160;
|
||||
private int generalPrice = 8;
|
||||
|
||||
/**
|
||||
* This method is evoked if the user is eligible to win, and chooses to end the game (by winning).
|
||||
*/
|
||||
public void retire(){
|
||||
player.setRetire(true);
|
||||
System.out.println("You win!");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the player instance variable equal to a copy of the parameter -- a copy is used for encapsulation purposes.
|
||||
*
|
||||
* @param player is a Player object that will replace the current instance of the player instance variable.
|
||||
*/
|
||||
public void setPlayer(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the player instance variable. The method returns a copy of the instance variable for encapsulation purposes.
|
||||
*
|
||||
* @return playerDummy -- playerDummy is a copy of the player instance variable.
|
||||
*/
|
||||
public Player getPlayer(){
|
||||
Player playerDummy = new Player(player);
|
||||
return playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* constructor; only runs when a Player object is provided. The constructor is fully encapsulated.
|
||||
*
|
||||
* @param player is a Player object that will be copied and the player instance variable is set to the copy.
|
||||
*/
|
||||
public TaipanShop(Player player){
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
public int getCargoSpace() {
|
||||
return cargoSpace;
|
||||
}
|
||||
|
||||
public void setCargoSpace(int cargoSpace) {
|
||||
if(cargoSpace > 0){
|
||||
this.cargoSpace = cargoSpace;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getter for opiumPrice instance variable.
|
||||
*
|
||||
* @return opiumPrice -- the price of opium in the shop
|
||||
*/
|
||||
public int getOpiumPrice() {
|
||||
return opiumPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter for the opiumPrice instance variable. Runs as long as the parameter is greater than 0.
|
||||
*
|
||||
* @param opiumPrice -- what the instance variable opiumPrice should be changed to.
|
||||
*/
|
||||
public void setOpiumPrice(int opiumPrice) {
|
||||
if(opiumPrice > 0){
|
||||
this.opiumPrice = opiumPrice;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getter for silkPrice instance variable.
|
||||
*
|
||||
* @return silkPrice -- the price of silk in the shop.
|
||||
*/
|
||||
public int getSilkPrice() {
|
||||
return silkPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter for the silkPrice instance variable. Runs as long as the parameter is greater than 0.
|
||||
*
|
||||
* @param silkPrice -- what the instance variable silkPrice should be changed to.
|
||||
*/
|
||||
public void setSilkPrice(int silkPrice) {
|
||||
if(silkPrice > 0){
|
||||
this.silkPrice = silkPrice;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getter for armsPrice instance variable.
|
||||
*
|
||||
* @return armsPrice -- the price of arms in the shop.
|
||||
*/
|
||||
public int getArmsPrice() {
|
||||
return armsPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter for the armsPrice instance variable. Runs as long as the parameter is greater than 0.
|
||||
*
|
||||
* @param armsPrice -- what the instance variable armsPrice should be changed to.
|
||||
*/
|
||||
public void setArmsPrice(int armsPrice) {
|
||||
if(armsPrice > 0){
|
||||
this.armsPrice = armsPrice;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getter for generalPrice instance variable.
|
||||
*
|
||||
* @return generalPrice -- the price of general cargo in the shop.
|
||||
*/
|
||||
public int getGeneralPrice() {
|
||||
return generalPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter for the generalPrice instance variable. Runs as long as the parameter is greater than 0.
|
||||
*
|
||||
* @param generalPrice -- what the instance variable generalPrice should be changed to.
|
||||
*/
|
||||
public void setGeneralPrice(int generalPrice) {
|
||||
if(generalPrice > 0){
|
||||
this.generalPrice = generalPrice;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* this method is evoked if the user has decided to travel elsewhere.
|
||||
*/
|
||||
public void travel(){
|
||||
Travel travel = new Travel(player);
|
||||
travel.travelTo();
|
||||
player = travel.getPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
* this method is evoked if the user wants to use the warehouse to store items or take items out.
|
||||
*/
|
||||
public void warehouse(){
|
||||
Warehouse warehouse = new Warehouse(player);
|
||||
warehouse.changeWarehouse();
|
||||
player = warehouse.getPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
* this method is evoked if the user wants to use the bank to deposit or withdraw money.
|
||||
*/
|
||||
public void bank(){
|
||||
Bank bank = new Bank(player);
|
||||
bank.bank();
|
||||
player = bank.getPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
* this method is evoked if the user wants to use get a loan or pay a loan off.
|
||||
*/
|
||||
public void loan(){
|
||||
loanShark loan = new loanShark(player);
|
||||
loan.loanMoney();
|
||||
player = loan.getPlayer();
|
||||
}
|
||||
|
||||
private void updatePrices(){
|
||||
/**
|
||||
* this method is when the shop is accessed, randomizing the prices of all the items.
|
||||
*/
|
||||
public void updatePrices(){
|
||||
String s = "\n" + player.getName() + ", the price of ";
|
||||
double value = 80*Math.random();
|
||||
Random rand = new Random();
|
||||
@@ -112,6 +174,8 @@ public class TaipanShop {
|
||||
silkPrice = (rand.nextInt(201) + 60)*10;
|
||||
armsPrice = (rand.nextInt(21) + 6)*10;
|
||||
generalPrice = rand.nextInt(17) + 4;
|
||||
|
||||
// there is a 10% chance that the price of an item is increased/decreased beyond its regular range.
|
||||
if(value < 8){
|
||||
if(value < 2){
|
||||
if(value < 1){
|
||||
@@ -149,12 +213,15 @@ public class TaipanShop {
|
||||
}
|
||||
}
|
||||
|
||||
private void printShop(){
|
||||
currentCargo = player.getOpiumHeld()+player.getGuns()*10+player.getSilkHeld()+player.getArmsHeld()+player.getGeneralHeld();
|
||||
if(cargoSpace - currentCargo < 0){
|
||||
/**
|
||||
* this method prints the shop UI and the player's inventory and status.
|
||||
*/
|
||||
public void printShop(){
|
||||
int currentCargo = player.getOpiumHeld()+player.getGuns()*10+player.getSilkHeld()+player.getArmsHeld()+player.getGeneralHeld();
|
||||
if(player.getCargoSpace() - currentCargo < 0){
|
||||
System.out.println("Hold: Overloaded" + " Guns: " + player.getGuns() + " HP: " + player.getHP() +"%");
|
||||
}else{
|
||||
System.out.println("Hold: " + (cargoSpace-currentCargo) + " Guns: " + player.getGuns() + " HP: " + player.getHP() +"%");
|
||||
System.out.println("Hold: " + (player.getCargoSpace()-currentCargo) + " Guns: " + player.getGuns() + " HP: " + player.getHP() +"%");
|
||||
}
|
||||
System.out.println("-------------------------------------------------------------");
|
||||
System.out.println(" Opium: " + player.getOpiumHeld() + " Silk: " + player.getSilkHeld());
|
||||
@@ -166,7 +233,14 @@ public class TaipanShop {
|
||||
System.out.println(" Arms: " + armsPrice + " General: " + generalPrice);
|
||||
}
|
||||
|
||||
public void atLocationOne(boolean notDone, Scanner input){
|
||||
/**
|
||||
* This method is evoked if the user is at the location one port.
|
||||
*/
|
||||
public void atLocationOne(){
|
||||
boolean notDone = true;
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// as long as the user does not enter a valid input, the code will run in a loop forever.
|
||||
while(notDone){
|
||||
printShop();
|
||||
System.out.println("\nShall I Buy, Sell, Visit Bank, Get Loans, Transfer Cargo, or Quit Trading?");
|
||||
@@ -174,6 +248,8 @@ public class TaipanShop {
|
||||
if (response.equalsIgnoreCase("B")) {
|
||||
boolean notDone2 = true;
|
||||
System.out.println("What do you wish me to buy, " + player.getName() + "?");
|
||||
|
||||
// when buying an item, the user must have the right amount of money, and buy non-negative amounts.
|
||||
while (notDone2) {
|
||||
response = input.nextLine();
|
||||
if (response.equalsIgnoreCase("O")) {
|
||||
@@ -236,7 +312,8 @@ public class TaipanShop {
|
||||
|
||||
}
|
||||
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
} // when selling, the user must enter a non-negative amount of items, and not more than what they have.
|
||||
else if (response.equalsIgnoreCase("S")) {
|
||||
boolean notDone2 = true;
|
||||
System.out.println("What do you wish me to sell, " + player.getName() + "?");
|
||||
while (notDone2) {
|
||||
@@ -307,14 +384,22 @@ public class TaipanShop {
|
||||
warehouse();
|
||||
}else if (response.equalsIgnoreCase("G")||response.equalsIgnoreCase("L")) {
|
||||
loan();
|
||||
}else if (response.equalsIgnoreCase("Q")) {
|
||||
} // if the user wishes to quit trading, they may do so. Doing this breaks them out of the loop.
|
||||
else if (response.equalsIgnoreCase("Q")) {
|
||||
travel();
|
||||
notDone = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void notAtLocationOne(boolean notDone, Scanner input){
|
||||
/**
|
||||
* This method is evoked when the user is at any port other than location one.
|
||||
*/
|
||||
public void notAtLocationOne(){
|
||||
boolean notDone = true;
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// as long as the user does not enter a valid input, the code will run in a loop forever.
|
||||
while(notDone){
|
||||
printShop();
|
||||
System.out.println("\nShall I Buy, Sell, or Quit Trading?");
|
||||
@@ -322,6 +407,8 @@ public class TaipanShop {
|
||||
if (response.equalsIgnoreCase("B")) {
|
||||
boolean notDone2 = true;
|
||||
System.out.println("What do you wish me to buy, " + player.getName() + "?");
|
||||
|
||||
// when buying an item, the user must have the right amount of money, and buy non-negative amounts.
|
||||
while (notDone2) {
|
||||
response = input.nextLine();
|
||||
if (response.equalsIgnoreCase("O")) {
|
||||
@@ -384,7 +471,8 @@ public class TaipanShop {
|
||||
|
||||
}
|
||||
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
} // when selling, the user must enter a non-negative amount of items, and not more than what they have.
|
||||
else if (response.equalsIgnoreCase("S")) {
|
||||
boolean notDone2 = true;
|
||||
System.out.println("What do you wish me to sell, " + player.getName() + "?");
|
||||
while (notDone2) {
|
||||
@@ -447,14 +535,22 @@ public class TaipanShop {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("Q")) {
|
||||
} // if the user wishes to quit trading, they may do so. Doing this breaks them out of the loop.
|
||||
else if (response.equalsIgnoreCase("Q")) {
|
||||
travel();
|
||||
notDone = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void retireAndLocationOne(boolean notDone, Scanner input){
|
||||
/**
|
||||
* this method is run if the user is eligible to win, and is at location one.
|
||||
*/
|
||||
public void retireAndLocationOne(){
|
||||
boolean notDone = true;
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// as long as the user does not enter a valid input, the code will run in a loop forever.
|
||||
while(notDone){
|
||||
printShop();
|
||||
System.out.println("\nShall I Buy, Sell, Visit Bank, Transfer Cargo, Get Loans, Retire, or Quit Trading?");
|
||||
@@ -462,6 +558,8 @@ public class TaipanShop {
|
||||
if (response.equalsIgnoreCase("B")) {
|
||||
boolean notDone2 = true;
|
||||
System.out.println("What do you wish me to buy, " + player.getName() + "?");
|
||||
|
||||
// when buying an item, the user must have the right amount of money, and buy non-negative amounts.
|
||||
while (notDone2) {
|
||||
response = input.nextLine();
|
||||
if (response.equalsIgnoreCase("O")) {
|
||||
@@ -523,7 +621,8 @@ public class TaipanShop {
|
||||
}
|
||||
}
|
||||
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
} // when selling, the user must enter a non-negative amount of items, and not more than what they have.
|
||||
else if (response.equalsIgnoreCase("S")) {
|
||||
boolean notDone2 = true;
|
||||
System.out.println("What do you wish me to sell, " + player.getName() + "?");
|
||||
while (notDone2) {
|
||||
@@ -594,26 +693,34 @@ public class TaipanShop {
|
||||
warehouse();
|
||||
} else if (response.equalsIgnoreCase("G")||response.equalsIgnoreCase("L")) {
|
||||
loan();
|
||||
}else if (response.equalsIgnoreCase("Q")) {
|
||||
} // if the user wishes to quit trading, they may do so. Doing this breaks them out of the loop.
|
||||
else if (response.equalsIgnoreCase("Q")) {
|
||||
travel();
|
||||
notDone = false;
|
||||
} else if (response.equalsIgnoreCase("R")) {
|
||||
} // if the user wishes to retire and win the game, they may do so. Doing this breaks them out of the loop.
|
||||
else if (response.equalsIgnoreCase("R")) {
|
||||
retire();
|
||||
notDone = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* the general method that utilizes all the other methods to form a fully functioning shop.
|
||||
*/
|
||||
public void shop() {
|
||||
updatePrices();
|
||||
Scanner input = new Scanner(System.in);
|
||||
boolean notDone = true;
|
||||
|
||||
// first case is triggered if the user is at location one, and has less than $1 million net worth
|
||||
if (player.getLocation() == 1 && player.getBank()+player.getMoney()-player.getDebt() < 1000000) {
|
||||
atLocationOne(notDone, input);
|
||||
}else if(player.getLocation() != 1) {
|
||||
notAtLocationOne(notDone, input);
|
||||
}else{
|
||||
retireAndLocationOne(notDone, input);
|
||||
atLocationOne();
|
||||
} // the second case is triggered if the user is at a location other than location one.
|
||||
else if(player.getLocation() != 1) {
|
||||
notAtLocationOne();
|
||||
} // the last case is triggered when the other conditions are not met; it is triggered when the user has a net
|
||||
// worth that is greater than or equal to $1 million and is at location one.
|
||||
else{
|
||||
retireAndLocationOne();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,21 +5,42 @@ public class Travel {
|
||||
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* sets the player instance variable equal to a copy of the parameter -- a copy is used for encapsulation purposes.
|
||||
*
|
||||
* @param player is a Player object that will replace the current instance of the player instance variable.
|
||||
*/
|
||||
public void setPlayer(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for obtaining a player object.
|
||||
*
|
||||
* @return returns player object
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
Player playerDummy = new Player(player);
|
||||
return playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* constructor; only runs when a Player object is provided. The constructor is fully encapsulated.
|
||||
*
|
||||
* @param player is a Player object that will be copied and the player instance variable is set to the copy.
|
||||
*/
|
||||
public Travel(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* When provided a location number: the method returns a print statement stating the location's name and call another
|
||||
* method to change the location of the Player object.
|
||||
*
|
||||
* @param locationOfTravel is a Player object that will be copied and the player instance variable is set to the copy.
|
||||
*/
|
||||
private void seaAtlas(int locationOfTravel) {
|
||||
switch (locationOfTravel) {
|
||||
case 1:
|
||||
@@ -53,6 +74,12 @@ public class Travel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on random chance either attacks the player with enemy ships, throws them to a different location or does nothing.
|
||||
*
|
||||
* @param locationOfTravel is used to see where the player is going to travel, just in case their location is changed
|
||||
* by a typhoon.
|
||||
**/
|
||||
private void randomEventSea(int locationOfTravel) throws Exception {
|
||||
Random rand = new Random();
|
||||
int randGenNum = rand.nextInt(3) + 1;
|
||||
@@ -60,15 +87,25 @@ public class Travel {
|
||||
peasantFleet();
|
||||
}else if (randGenNum == 2) {
|
||||
disaster(locationOfTravel);
|
||||
}
|
||||
System.out.println("We made it!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on random chance either throws the player character off course, or continues them on their way to their
|
||||
* destination.
|
||||
*
|
||||
* @param locationOfTravel is used to see where the player is going to travel, just in case their location is changed
|
||||
* by a typhoon.
|
||||
**/
|
||||
private void disaster(int locationOfTravel) {
|
||||
//Tells player that there is a storm approaching.
|
||||
System.out.print("Storm " + player.getName() + "! ");
|
||||
Random rand = new Random();
|
||||
int randGenNum = rand.nextInt(5) + 1;
|
||||
|
||||
//If the player lands within this range, nothing happens to them
|
||||
//Else they randomly get thrown into a location they weren't planning on going to(Anything but location of Travel).
|
||||
if (randGenNum <= 2) {
|
||||
System.out.println(" We made it through!");
|
||||
}else {
|
||||
@@ -82,26 +119,39 @@ public class Travel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To use the peasant fleet class while still maintaining encapsulation we have to create a ShipWarefare object and
|
||||
* run the method from there. After the method has been run we can update the player object in this class.
|
||||
* @throws Exception throws Exception so that we can use the time library to make the player if we want to.
|
||||
**/
|
||||
public void peasantFleet() throws Exception {
|
||||
ShipWarfare attackShip = new ShipWarfare(player);
|
||||
attackShip.peasantFleetAttack();
|
||||
player = attackShip.getPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
*Used to travel between different areas inside of the game world.
|
||||
* If the player's inventory is too full it won't run.
|
||||
* Also calculates loan and bank interest between the jumps between islands.
|
||||
**/
|
||||
public void travelTo() {
|
||||
Scanner keyboard = new Scanner(System.in);
|
||||
String response;
|
||||
int tempInt;
|
||||
boolean hasTraveled = false;
|
||||
|
||||
//Only lets the player leave the port if their inventory is greater than or equal to the sum of the items in the inventory.
|
||||
if(player.getCargoSpace() >= (player.getOpiumHeld()+ (player.getGuns()*10)+player.getSilkHeld() + player.getArmsHeld() + player.getGeneralHeld())){
|
||||
while (true) {
|
||||
System.out.println("\n" + player.getName() + ", do you wish to go to:\n");
|
||||
System.out.println("1) Hong Kong, 2) Shanghai, 3) Nagasaki,\n4) Saigon, 5) Manila, 6) Singapore, or 7) Batavia?");
|
||||
|
||||
response = keyboard.nextLine();
|
||||
//Just in case the player types something that was not intended. It will refresh the question and ask it again
|
||||
try {
|
||||
tempInt = Integer.parseInt(response);
|
||||
System.out.println(tempInt + " " + player.getLocation());
|
||||
//Makes sure you can't travel to your own location.
|
||||
if (tempInt != player.getLocation()) {
|
||||
randomEventSea(tempInt);
|
||||
seaAtlas(tempInt);
|
||||
@@ -117,4 +167,8 @@ public class Travel {
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
System.out.println(player.getName() + " the cargo is too heavy! We can't set sail!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* The purpose of this class is to create a warehouse where the goods
|
||||
* can be safely stored without holing space on the ship!
|
||||
*/
|
||||
public class Warehouse {
|
||||
/*private int wOpium = 0;
|
||||
private int wSilk = 0;
|
||||
@@ -7,43 +11,75 @@ public class Warehouse {
|
||||
private int wArms = 0;*/
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* setter method that takes in a Player object as an argument.
|
||||
*
|
||||
* @param player object of the class Player
|
||||
*/
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
Player playerDumy = new Player(player);
|
||||
this.player = playerDumy;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for obtaining a player object.
|
||||
*
|
||||
* @return returns player object
|
||||
*/
|
||||
|
||||
public Player getPlayer() {
|
||||
Player playerDummy = new Player(player);
|
||||
return playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Constructor that takes in a type player as a parameter
|
||||
*
|
||||
* @param player object of the class Player
|
||||
*/
|
||||
|
||||
public Warehouse(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method adds an amount of a certain good
|
||||
* the user is prompted to enter the amount they would like to
|
||||
* add followed by the good they would like to add to the warehouse.
|
||||
* the method checks if the player has sufficient goods to transfer, and if the player does
|
||||
* then the method executes the transfer
|
||||
*
|
||||
*/
|
||||
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();
|
||||
amount = keyboard.nextLine();//Asks the user for the amount of the good they would like to add
|
||||
/*The try function ensures that the program does not crash
|
||||
due to any errors while giving the program an incorrect input*/
|
||||
try {
|
||||
//The if statement checks that you have enough resources to make the transfer
|
||||
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 {
|
||||
}
|
||||
//Else statement lets the user know that they do not hav enough goods to make the requested transfer
|
||||
else {
|
||||
System.out.println("Nice try but you don't have any items of that quantity!");
|
||||
askGood = false;
|
||||
}
|
||||
//Ensures that goods are only transferred if they have the specified amount
|
||||
//The user is prompted to enter which good they want to transfer
|
||||
if (askGood == true) {
|
||||
String good;
|
||||
System.out.println("Please enter a good to transfer O, S, G, A :");
|
||||
good = keyboard.nextLine();
|
||||
int held = 0;
|
||||
//The following set of loops check to see which good the user has selected and makes the transfer
|
||||
if (Integer.parseInt(amount) > 0) {
|
||||
if (good.equalsIgnoreCase("O")) {
|
||||
if (player.getOpiumHeld() >= Integer.parseInt(amount)) {
|
||||
@@ -81,36 +117,57 @@ public class Warehouse {
|
||||
System.out.println("You don't even have that much Arms!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
//Ensures no negative amounts are entered
|
||||
else {
|
||||
System.out.println("Sorry this transfer cannot be made");
|
||||
}
|
||||
}
|
||||
//If the program errors out this is the message displayed and the method is re-run, so that the game does not end.
|
||||
} catch (Exception e) {
|
||||
System.out.println("Wait, that's not a valid input please try again");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method removes an amount of a certain good
|
||||
* the user is prompted to enter the amount they would like to
|
||||
* remove followed by the good they would like to remove from the warehouse.
|
||||
* the method checks if the player has sufficient goods to transfer, and if the player does
|
||||
* then the method executes the transfer
|
||||
*
|
||||
*/
|
||||
|
||||
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);
|
||||
//Prompts the user for the amount they would like to remove
|
||||
amount = keyboard.nextLine();
|
||||
//The if statement checks that you have enough resources to make the transfer
|
||||
try {
|
||||
//The if statement checks that you have enough resources to make the transfer
|
||||
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 {
|
||||
}
|
||||
//Else statement lets the user know that they do not hav enough goods to make the requested transfer
|
||||
else {
|
||||
System.out.println("Nice try but you don't have any items of that quantity in the warehouse!");
|
||||
askGood = false;
|
||||
}
|
||||
|
||||
//Ensures that goods are only transferred if they have the specified amount
|
||||
//The user is prompted to enter which good they want to transfer
|
||||
|
||||
if (askGood == true) {
|
||||
String good;
|
||||
System.out.println("Please enter a good to transfer O, S, G, A :");
|
||||
good = keyboard.nextLine();
|
||||
int held = 0;
|
||||
//The following set of loops check to see which good the user has selected and makes the transfer and amount > 0
|
||||
if (Integer.parseInt(amount) > 0) {
|
||||
if (good.equalsIgnoreCase("O")) {
|
||||
if (player.getwOpium() >= Integer.parseInt(amount)) {
|
||||
@@ -147,16 +204,24 @@ public class Warehouse {
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
//Ensures the value entered is positive
|
||||
else {
|
||||
System.out.println("Sorry this transfer cannot be made");
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
}
|
||||
//If the program errors out this is the message displayed and the method is re-run, so that the game does not end.
|
||||
catch (Exception e){
|
||||
System.out.println("Wait, that's not a valid input please try again");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method prints the stock that is in the warehouse currently using the get and set
|
||||
* methods from the player class. This is to allow the user to be able to know how much they have
|
||||
* stored in the warehouse
|
||||
*/
|
||||
public void showWarehouse() {
|
||||
System.out.println("--------------------\nWarehouse\n--------------------");
|
||||
System.out.println("Opium : " + player.getwOpium());
|
||||
@@ -165,7 +230,11 @@ public class Warehouse {
|
||||
System.out.println("Arms : " + player.getwArms());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method combines the add and remove methods and prompts the user to
|
||||
* enter what they would like to do. Add or remove and accordingly invokes
|
||||
* the required methods
|
||||
*/
|
||||
public void changeWarehouse() {
|
||||
boolean keepGoing = true;
|
||||
while (keepGoing) {
|
||||
@@ -187,6 +256,7 @@ public class Warehouse {
|
||||
}
|
||||
|
||||
String check;
|
||||
//Check to see if the player wants to continue in the warehouse or they are done
|
||||
System.out.println("Would you like to do any other business? Y / N?");
|
||||
check = keyboard.nextLine();
|
||||
check = keyboard.nextLine();
|
||||
@@ -199,7 +269,4 @@ public class Warehouse {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,38 +2,86 @@ import java.util.Scanner;
|
||||
|
||||
public class loanShark {
|
||||
private Player player;
|
||||
/**
|
||||
* setter method that takes in a Player object as an argument.
|
||||
*
|
||||
* @param player object of the class Player
|
||||
*/
|
||||
public void setPlayer(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter method for obtaining a player object.
|
||||
*
|
||||
* @return returns player object
|
||||
*/
|
||||
public Player getPlayer(){
|
||||
Player playerDummy = new Player(player);
|
||||
return playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Constructor that takes in a type player as a parameter
|
||||
*
|
||||
* @param player object of the class Player
|
||||
*/
|
||||
public loanShark(Player player){
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* This methods purpose is to loan the player the funds it wants
|
||||
* or pay its outstanding debts. The method prompts the user if they
|
||||
* would like to borrow money or repay. depending on what the player chooses
|
||||
* the corresponding loop is evoked. The player can only be loaned 2 times the
|
||||
* money they have minus the debt id their debt exceeds the cash balance, the loan
|
||||
* cannot be given.
|
||||
*/
|
||||
public void loanMoney() {
|
||||
boolean keepGoing = true;
|
||||
while(keepGoing) {
|
||||
String check;
|
||||
Scanner keyboard = new Scanner(System.in);
|
||||
System.out.println("Would you like to return money or borrow money?");
|
||||
//Prompts the user or what they would like to do
|
||||
check = keyboard.nextLine();
|
||||
//If the user chooses to return money, the money is subtracted from the cash amount and debt
|
||||
if(check.equalsIgnoreCase("r")){
|
||||
int returnAsk = 0;
|
||||
System.out.println("Please enter how much you would like to return?");
|
||||
returnAsk = keyboard.nextInt();
|
||||
if(returnAsk <= player.getDebt() && returnAsk >= 0) {
|
||||
player.setDebt(player.getDebt() - returnAsk);
|
||||
player.setMoney(player.getMoney() - returnAsk);
|
||||
}
|
||||
//if you try to return more money than you owe it wont allow you to
|
||||
else if(returnAsk > player.getDebt()){
|
||||
System.out.println("You don't need to return that much!");
|
||||
}
|
||||
//No negative amounts are allowed
|
||||
else{
|
||||
System.out.println("You can't return a negative amount.");
|
||||
}
|
||||
|
||||
}
|
||||
//If the user chooses to borrow, the money is added to cash and the debt is increased
|
||||
else if(check.equalsIgnoreCase("b")){
|
||||
int loanAsk = 0;
|
||||
System.out.println("Please enter how much you would like to borrow");
|
||||
Scanner keyboard = new Scanner(System.in);
|
||||
//Prompts user for the amount they would like to borrow
|
||||
loanAsk = keyboard.nextInt();
|
||||
if(loanAsk <= 2*(player.getMoney() - player.getDebt())) {
|
||||
if(loanAsk <= 2*(player.getMoney() - player.getDebt())&& loanAsk >= 0) {
|
||||
player.setDebt(player.getDebt() + loanAsk);
|
||||
player.setMoney(player.getMoney() + loanAsk);
|
||||
}
|
||||
//updated
|
||||
//If the requested money exceeds 2*(cash - debt) then the loan cannot be given
|
||||
else{
|
||||
System.out.println("Sorry you can't be loaned that much");
|
||||
break;
|
||||
}
|
||||
String check;
|
||||
}
|
||||
//Asks the player if they have any other things to do with the load shark
|
||||
System.out.println("Would you like to do any other business? Y / N?");
|
||||
check = keyboard.nextLine();
|
||||
check = keyboard.nextLine();
|
||||
|
||||
@@ -2,23 +2,46 @@ public class main {
|
||||
|
||||
private Player player = new Player();
|
||||
|
||||
/**
|
||||
* getter method for the Player object player.
|
||||
*
|
||||
* @return returns a copy of the object player
|
||||
*/
|
||||
|
||||
public Player getPlayer(){
|
||||
Player copy = new Player(player);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Taipan shop with the players stats after the player finishes shopping, it updates the player object and returns it.
|
||||
*
|
||||
* @param shop player object from the main class used to update the shop class
|
||||
*/
|
||||
|
||||
public void shop(TaipanShop shop){
|
||||
shop.setPlayer(player);
|
||||
shop.shop();
|
||||
player = shop.getPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the player object with 5 guns or $400 and $5000 debt.
|
||||
*
|
||||
* @param start player object from the main class used to update the start class
|
||||
*/
|
||||
|
||||
public void start(Start start){
|
||||
start.setPlayer(player);
|
||||
start.intialize();
|
||||
start.initialize();
|
||||
player = start.getPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates main class with player data and starts the game.
|
||||
* The game will only run as long as the player has not retired or has been destroyed.
|
||||
* @param args Just the console for the player to look at.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
main main = new main();
|
||||
TaipanShop littyShop = new TaipanShop(main.getPlayer());
|
||||
|
||||
Reference in New Issue
Block a user