Redid a bunch of commenting making sure that every method was commented.

This commit is contained in:
2019-04-12 03:54:20 -06:00
parent 03ff12b832
commit f89c1aa209
28 changed files with 508 additions and 218 deletions

View File

@@ -1,11 +1,16 @@
package text;
import logic.BankLogic;
import logic.Player;
import java.util.Scanner;
public class BankText extends Player {
/**
* Class Constructor that takes in a type player as a parameter
* @param player object of the class Player
*/
public BankText(Player player) {
Player playerDummy = new Player(player);
setPlayer(playerDummy);
@@ -28,52 +33,86 @@ public class BankText extends Player {
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 <= getBank()){
setMoney(withdraw + getMoney());
setBank(getBank()-withdraw);
notDone2 = false;
check = 1;
}
}
check = withdraw(input, check);
}
//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 <= getMoney()){
setBank(deposit + getBank());
setMoney(getMoney()-deposit);
notDone2 = false;
check = 1;
}
}
check = deposit(input, check);
}
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();
response = input.nextLine();
if(response.equalsIgnoreCase("Y")){
notDone3 = false;
}else if(response.equalsIgnoreCase("N")){
notDone = false;
notDone3 = false;
}
}
notDone = notContinue(input, notDone);
}
}
}
/**
* Asks the user if they want to continue staying in Bank
* @param input The Scanner object which is used for asking user questions
* @param notDone Boolean statement which if is false stops the loop in the Bank method
* @return a boolean value which can turn off the original while loop this method is inside
*/
public boolean notContinue(Scanner input, boolean notDone) {
String response;
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();
response = input.nextLine();
if(response.equalsIgnoreCase("Y")){
notDone3 = false;
}else if(response.equalsIgnoreCase("N")){
notDone = false;
notDone3 = false;
}
}
return notDone;
}
/**
* Asks the user how much they want to deposit
* @param input The Scanner object which is used for asking user questions
* @param check an integer value which changes depending on the stages of the bank class
* @return a boolean value which can turn off the original while loop this method is inside
*/
public int deposit(Scanner input, int check) {
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 <= getMoney()){
BankLogic bankLogic = new BankLogic(getPlayer());
bankLogic.depositing(deposit);
setPlayer(bankLogic.getPlayer());
notDone2 = false;
check = 1;
}
}
return check;
}
/**
* Asks the user how much they want to withdrawe
* @param input The Scanner object which is used for asking user questions
* @param check an integer value which changes depending on the stages of the bank class
* @return a boolean value which can turn off the original while loop this method is inside
*/
public int withdraw(Scanner input, int check) {
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 <= getBank()){
BankLogic bankLogic = new BankLogic(getPlayer());
bankLogic.withdrawing(withdraw);
setPlayer(bankLogic.getPlayer());
notDone2 = false;
check = 1;
}
}
return check;
}
}