bunch of revisions, still in progress
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import java.sql.SQLOutput;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Bank{
|
||||
@@ -6,47 +7,62 @@ public class Bank{
|
||||
public void setPlayer(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
}
|
||||
|
||||
public Player getPlayer(){
|
||||
Player playerDummy = new Player(player);
|
||||
return playerDummy;
|
||||
}
|
||||
public Player getPlayer(){
|
||||
Player playerDummy = new Player(player);
|
||||
return playerDummy;
|
||||
}
|
||||
|
||||
public Bank(Player player){
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
public Bank(Player player){
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
public int promtMoney() {
|
||||
int addVal = 0;
|
||||
int retVal = 0;
|
||||
System.out.println("Please enter an amount");
|
||||
Scanner keyboard = new Scanner(System.in);
|
||||
addVal = keyboard.nextInt();
|
||||
if(addVal >= 0) {
|
||||
retVal = addVal;
|
||||
public void bank(){
|
||||
Scanner input = new Scanner(System.in);
|
||||
boolean notDone = true;
|
||||
int check = 0;
|
||||
while(notDone){
|
||||
System.out.println("Would you like to Withdraw or Deposit?");
|
||||
String response = input.nextLine();
|
||||
if(response.equalsIgnoreCase("W")){
|
||||
boolean notDone2 = true;
|
||||
while(notDone2){
|
||||
int withdraw = input.nextInt();
|
||||
if(withdraw <= player.getBank()){
|
||||
player.setMoney(withdraw + player.getMoney());
|
||||
player.setBank(player.getBank()-withdraw);
|
||||
notDone2 = false;
|
||||
check = 1;
|
||||
}
|
||||
}
|
||||
}else if(response.equalsIgnoreCase("D")){
|
||||
boolean notDone2 = true;
|
||||
while(notDone2){
|
||||
int deposit = input.nextInt();
|
||||
if(deposit <= player.getMoney()){
|
||||
player.setBank(deposit + player.getBank());
|
||||
player.setMoney(player.getMoney()-deposit);
|
||||
notDone2 = false;
|
||||
check = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(check == 1){
|
||||
boolean notDone3 = true;
|
||||
while(notDone3){
|
||||
System.out.println("Would you like to continue? Y/N");
|
||||
response = input.nextLine();
|
||||
if(response.equalsIgnoreCase("Y")){
|
||||
notDone3 = false;
|
||||
}else if(response.equalsIgnoreCase("N")){
|
||||
notDone = false;
|
||||
notDone3 = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public void addMoney() {
|
||||
int addMon = promtMoney();
|
||||
if(addMon >= 0) {
|
||||
player.setBank(promtMoney() + player.getMoney());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void removeMoney() {
|
||||
int subMon = promtMoney();
|
||||
if(subMon <= player.getMoney()) {
|
||||
player.setBank(subMon - player.getMoney());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addInterest() {
|
||||
player.setBank((int)((player.getBank() * 1.01)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,13 @@ public class Start
|
||||
{
|
||||
player.setGuns(5);
|
||||
}
|
||||
// purely for testing purposes.
|
||||
if(player.getName().equalsIgnoreCase("Vikram")){
|
||||
player.setMoney(999999999);
|
||||
player.setBank(999999999);
|
||||
player.setGuns(999);
|
||||
player.setHP(99999999);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -86,6 +86,24 @@ public class TaipanShop {
|
||||
player = travel.getPlayer();
|
||||
}
|
||||
|
||||
public void warehouse(){
|
||||
Warehouse warehouse = new Warehouse(player);
|
||||
warehouse.changeWarehouse();
|
||||
player = warehouse.getPlayer();
|
||||
}
|
||||
|
||||
public void bank(){
|
||||
Bank bank = new Bank(player);
|
||||
bank.bank();
|
||||
player = bank.getPlayer();
|
||||
}
|
||||
|
||||
public void loan(){
|
||||
loanShark loan = new loanShark(player);
|
||||
loan.loanMoney();
|
||||
player = loan.getPlayer();
|
||||
}
|
||||
|
||||
private void updatePrices(){
|
||||
String s = "\n" + player.getName() + ", the price of ";
|
||||
double value = 80*Math.random();
|
||||
@@ -134,15 +152,15 @@ public class TaipanShop {
|
||||
private void printShop(){
|
||||
currentCargo = player.getOpiumHeld()+player.getGuns()*10+player.getSilkHeld()+player.getArmsHeld()+player.getGeneralHeld();
|
||||
if(cargoSpace - currentCargo < 0){
|
||||
System.out.println("Hold: Overloaded" + " Guns: " + player.getGuns());
|
||||
System.out.println("Hold: Overloaded" + " Guns: " + player.getGuns() + " HP: " + player.getHP() +"%");
|
||||
}else{
|
||||
System.out.println("Hold: " + (cargoSpace-currentCargo) + " Guns: " + player.getGuns());
|
||||
System.out.println("Hold: " + (cargoSpace-currentCargo) + " Guns: " + player.getGuns() + " HP: " + player.getHP() +"%");
|
||||
}
|
||||
System.out.println("-------------------------------------------------------------");
|
||||
System.out.println(" Opium: " + player.getOpiumHeld() + " Silk: " + player.getSilkHeld());
|
||||
System.out.println(" Arms: " + player.getArmsHeld() + " General: " + player.getGeneralHeld());
|
||||
System.out.println("-------------------------------------------------------------");
|
||||
System.out.println("Cash: " + player.getMoney() + " Bank: " + player.getBank()+"\n");
|
||||
System.out.println("Cash: " + player.getMoney() + " Bank: " + player.getBank()+ " Debt: " + player.getDebt()+"\n");
|
||||
System.out.println(player.getName() + ", present prices per unit here are:");
|
||||
System.out.println(" Opium: " + opiumPrice + " Silk: " + silkPrice);
|
||||
System.out.println(" Arms: " + armsPrice + " General: " + generalPrice);
|
||||
@@ -151,7 +169,7 @@ public class TaipanShop {
|
||||
public void atLocationOne(boolean notDone, Scanner input){
|
||||
while(notDone){
|
||||
printShop();
|
||||
System.out.println("\nShall I Buy, Sell, Visit Bank, Transfer Cargo, or Quit Trading?");
|
||||
System.out.println("\nShall I Buy, Sell, Visit Bank, Get Loans, Transfer Cargo, or Quit Trading?");
|
||||
String response = input.next();
|
||||
if (response.equalsIgnoreCase("B")) {
|
||||
boolean notDone2 = true;
|
||||
@@ -284,10 +302,12 @@ public class TaipanShop {
|
||||
}
|
||||
|
||||
} else if (response.equalsIgnoreCase("V")) {
|
||||
System.out.println("\n*** PLACEHOLDER FOR BANK ***\n");
|
||||
bank();
|
||||
} else if (response.equalsIgnoreCase("T")) {
|
||||
System.out.println("\n*** PLACEHOLDER FOR WAREHOUSE ***\n");
|
||||
} else if (response.equalsIgnoreCase("Q")) {
|
||||
warehouse();
|
||||
}else if (response.equalsIgnoreCase("G")||response.equalsIgnoreCase("L")) {
|
||||
loan();
|
||||
}else if (response.equalsIgnoreCase("Q")) {
|
||||
travel();
|
||||
notDone = false;
|
||||
}
|
||||
@@ -437,7 +457,7 @@ public class TaipanShop {
|
||||
public void retireAndLocationOne(boolean notDone, Scanner input){
|
||||
while(notDone){
|
||||
printShop();
|
||||
System.out.println("\nShall I Buy, Sell, Visit Bank, Transfer Cargo, Retire, or Quit Trading?");
|
||||
System.out.println("\nShall I Buy, Sell, Visit Bank, Transfer Cargo, Get Loans, Retire, or Quit Trading?");
|
||||
String response = input.next();
|
||||
if (response.equalsIgnoreCase("B")) {
|
||||
boolean notDone2 = true;
|
||||
@@ -569,10 +589,12 @@ public class TaipanShop {
|
||||
}
|
||||
|
||||
} else if (response.equalsIgnoreCase("V")) {
|
||||
System.out.println("\n*** PLACEHOLDER FOR BANK ***\n");
|
||||
bank();
|
||||
} else if (response.equalsIgnoreCase("T")) {
|
||||
System.out.println("\n*** PLACEHOLDER FOR WAREHOUSE ***\n");
|
||||
} else if (response.equalsIgnoreCase("Q")) {
|
||||
warehouse();
|
||||
}else if (response.equalsIgnoreCase("G")||response.equalsIgnoreCase("L")) {
|
||||
loan();
|
||||
}else if (response.equalsIgnoreCase("Q")) {
|
||||
travel();
|
||||
notDone = false;
|
||||
} else if (response.equalsIgnoreCase("R")) {
|
||||
|
||||
@@ -106,6 +106,8 @@ public class Travel {
|
||||
randomEventSea(tempInt);
|
||||
seaAtlas(tempInt);
|
||||
hasTraveled = true;
|
||||
player.setBank((int)(player.getBank() * 1.01));
|
||||
player.setDebt((int)(player.getDebt() * 1.01));
|
||||
} else System.out.println("\nYou're already here " + player.getName() + ".");
|
||||
} catch (Exception e) {
|
||||
System.out.print("\nSorry, " + player.getName() + " could you say that again?");
|
||||
|
||||
@@ -44,7 +44,6 @@ public class Warehouse {
|
||||
}
|
||||
String good;
|
||||
System.out.println("Please enter a good to transfer O, S, G, A :");
|
||||
Scanner keyboard = new Scanner(System.in);
|
||||
good = keyboard.nextLine();
|
||||
int held = 0;
|
||||
if (amount > 0) {
|
||||
@@ -96,7 +95,6 @@ public class Warehouse {
|
||||
|
||||
String good;
|
||||
System.out.println("Please enter a good to transfer O, S, G, A :");
|
||||
Scanner keyboard = new Scanner(System.in);
|
||||
good = keyboard.nextLine();
|
||||
int held = 0;
|
||||
if (amount > 0) {
|
||||
@@ -155,7 +153,6 @@ public class Warehouse {
|
||||
|
||||
String check;
|
||||
System.out.println("Would you like to do any other business? Y / N?");
|
||||
Scanner keyboard = new Scanner(System.in);
|
||||
check = keyboard.nextLine();
|
||||
|
||||
if(check.equalsIgnoreCase("Y")) {
|
||||
|
||||
@@ -2,46 +2,42 @@ import java.util.Scanner;
|
||||
|
||||
public class loanShark {
|
||||
private Player player;
|
||||
public void setPlayer(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
public void setPlayer(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
public Player getPlayer(){
|
||||
Player playerDummy = new Player(player);
|
||||
return playerDummy;
|
||||
}
|
||||
public Player getPlayer(){
|
||||
Player playerDummy = new Player(player);
|
||||
return playerDummy;
|
||||
}
|
||||
|
||||
public loanShark(Player player){
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
public loanShark(Player player){
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
public void loanMoney() {
|
||||
boolean keepGoing = true;
|
||||
while(keepGoing) {
|
||||
int loanAsk = 0;
|
||||
System.out.println("Please enter how much you would like to borrow");
|
||||
Scanner keyboard = new Scanner(System.in);
|
||||
loanAsk = keyboard.nextInt();
|
||||
int loanAsk = 0;
|
||||
System.out.println("Please enter how much you would like to borrow");
|
||||
Scanner keyboard = new Scanner(System.in);
|
||||
loanAsk = keyboard.nextInt();
|
||||
if(loanAsk <= 2*(player.getMoney() - player.getDebt())) {
|
||||
player.setDebt(player.getDebt() + loanAsk);
|
||||
player.setMoney(player.getMoney() + loanAsk);
|
||||
}
|
||||
String check;
|
||||
System.out.println("Would you like to do any other business? Y / N?");
|
||||
Scanner keyboard = new Scanner(System.in);
|
||||
check = keyboard.nextLine();
|
||||
|
||||
|
||||
if(check.equalsIgnoreCase("Y")) {
|
||||
keepGoing = true;
|
||||
}
|
||||
}
|
||||
else if(check.equalsIgnoreCase("N")) {
|
||||
keepGoing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void removeInterest() {
|
||||
player.setDebt((int)(player.getDebt() * 1.05));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,18 +19,6 @@ public class main {
|
||||
player = start.getPlayer();
|
||||
}
|
||||
|
||||
public void warehouse(Warehouse warehouse){
|
||||
warehouse.setPlayer(player);
|
||||
//warehouse.intialize();
|
||||
player = warehouse.getPlayer();
|
||||
}
|
||||
|
||||
public void bank(Bank bank){
|
||||
bank.setPlayer(player);
|
||||
//warehouse.intialize();
|
||||
player = bank.getPlayer();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
main main = new main();
|
||||
TaipanShop littyShop = new TaipanShop(main.getPlayer());
|
||||
|
||||
Reference in New Issue
Block a user