Small thing, changed an output of warehouse a bit, shows user its the warehouse they are concerned with.
This commit is contained in:
@@ -1,35 +1,62 @@
|
|||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Bank{
|
public class Bank{
|
||||||
|
private Player player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setter method that takes in a Player object as an argument.
|
||||||
|
*
|
||||||
|
* @param player object of the class Player
|
||||||
|
*/
|
||||||
|
|
||||||
private Player player;
|
|
||||||
public void setPlayer(Player player) {
|
public void setPlayer(Player player) {
|
||||||
Player playerDummy = new Player(player);
|
Player playerDummy = new Player(player);
|
||||||
this.player = playerDummy;
|
this.player = playerDummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer(){
|
/**
|
||||||
|
* getter method for obtaining a player object.
|
||||||
|
*
|
||||||
|
* @return returns player object
|
||||||
|
*/
|
||||||
|
|
||||||
|
public Player getPlayer(){
|
||||||
Player playerDummy = new Player(player);
|
Player playerDummy = new Player(player);
|
||||||
return playerDummy;
|
return playerDummy;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Class Constructor that takes in a type player as a parameter
|
||||||
|
*
|
||||||
|
* @param player object of the class Player
|
||||||
|
*/
|
||||||
|
|
||||||
public Bank(Player player){
|
public Bank(Player player){
|
||||||
Player playerDummy = new Player(player);
|
Player playerDummy = new Player(player);
|
||||||
this.player = playerDummy;
|
this.player = playerDummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bank(){
|
/**
|
||||||
|
* 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);
|
Scanner input = new Scanner(System.in);
|
||||||
boolean notDone = true;
|
boolean notDone = true;
|
||||||
int check = 0;
|
int check = 0;
|
||||||
while(notDone){
|
while(notDone){
|
||||||
|
//Prompt the user if they want to withdraw or deposit
|
||||||
System.out.println("Would you like to Withdraw or Deposit?");
|
System.out.println("Would you like to Withdraw or Deposit?");
|
||||||
String response = input.nextLine();
|
String response = input.nextLine();
|
||||||
|
//If user chose withdraw then subtract the amount from bank account and add it to cash
|
||||||
if(response.equalsIgnoreCase("W")){
|
if(response.equalsIgnoreCase("W")){
|
||||||
boolean notDone2 = true;
|
boolean notDone2 = true;
|
||||||
while(notDone2){
|
while(notDone2){
|
||||||
System.out.println("How much do you wish to Withdraw?");
|
System.out.println("How much do you wish to Withdraw?");
|
||||||
int withdraw = input.nextInt();
|
int withdraw = input.nextInt();
|
||||||
|
//Prompt the user for the amount and check if the bank has sufficient funds
|
||||||
if(withdraw <= player.getBank()){
|
if(withdraw <= player.getBank()){
|
||||||
player.setMoney(withdraw + player.getMoney());
|
player.setMoney(withdraw + player.getMoney());
|
||||||
player.setBank(player.getBank()-withdraw);
|
player.setBank(player.getBank()-withdraw);
|
||||||
@@ -37,9 +64,13 @@ public class Bank{
|
|||||||
check = 1;
|
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;
|
boolean notDone2 = true;
|
||||||
while(notDone2){
|
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?");
|
System.out.println("How much do you wish to Deposit?");
|
||||||
int deposit = input.nextInt();
|
int deposit = input.nextInt();
|
||||||
if(deposit <= player.getMoney()){
|
if(deposit <= player.getMoney()){
|
||||||
@@ -52,6 +83,7 @@ public class Bank{
|
|||||||
}
|
}
|
||||||
if(check == 1){
|
if(check == 1){
|
||||||
boolean notDone3 = true;
|
boolean notDone3 = true;
|
||||||
|
// Asks user if they would like to continue in bank or not
|
||||||
while(notDone3){
|
while(notDone3){
|
||||||
System.out.println("Would you like to continue? Y/N");
|
System.out.println("Would you like to continue? Y/N");
|
||||||
response = input.nextLine();
|
response = input.nextLine();
|
||||||
|
|||||||
Reference in New Issue
Block a user