Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi am encountering error in my javafx application in which after i enter numbers through my keypad and press the please enter button it just
Hi am encountering error in my javafx application in which after i enter numbers through my keypad and press the please enter button it just clears the text and does nothing else. i will share the codes with you please check the problem i have attached ATM, AtmApp code down below and for reference of other codes of the app i am attaching the images which contains Account.java and BalanceInquiry.java, BankDatabase.java and CashDispenser.java, Deposit.java, DepositSlot.java and Withdrawal.java
ATM.java
package atm.application;
import javafx.scene.control.TextArea;
public class ATM
attributes
private boolean userAuthenticated;
private int currentAccountNumber;
private TextArea text;
private BankDatabase bank;
private final static int BALANCEINQUIRY ;
private final static int WITHDRAWAL ;
private final static int DEPOSIT ;
private final static int EXIT ;
public ATMTextArea text
this.text text;
userAuthenticated false;
currentAccountNumber ;
bank new BankDatabase;
private void authenticateUserint accNo, int pin
userAuthenticated bank.authenticateUseraccNo pin;
if userAuthenticated
currentAccountNumber accNo;
displayMessage
Welcome";
else
displayMessage
Invalid accoung number of PIN. Please try again";
public void performTransactionsint sel
Transaction currentTransaction createTransactionsel;
if currentTransaction null
currentTransaction.execute;
private Transaction createTransactionint type
Transaction transaction null;
switch type
case BALANCEINQUIRY:
transaction new BalanceInquirycurrentAccountNumbertext, bank;
break;
case WITHDRAWAL:
transaction new WithdrawalcurrentAccountNumbertext,bank;
break;
case DEPOSIT:
transaction new DepositcurrentAccountNumber text, bank;
break;
return transaction;
private void displayMainMenu
text.clear;
displayMessageLine
Main Menu";
displayMessageLine View my balance";
displayMessageLine Withdraw cash";
displayMessageLine Deposit funds";
displayMessageLine Exit
;
displayMessageEnter a choice! ;
public void displayMessageString msg
text.appendTextmsg;
public void displayMessageLineString msg
text.appendTextmsg
;
AtmApp
package atm.application;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.scene.control.TextArea;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.BorderPane;
import javafx.geometry.Insets;
public static void mainString args
launchargs;
public void startStage primarystage
primarystage.setTitleApplication for ATM";
text new TextArea;
text.setEditablefalse;
Button digit new Button;
forint i ; i ; i
digiti new ButtonStringvalueOfi;
final int dig i;
digitisetOnActione
String current text.getText;
text.setTextcurrent dig;;
Button enter new ButtonPlease enter";
enter.setOnActione
try
int in Integer.parseInttextgetTexttrim;
atm.performTransactionsin;
text.clear;
catchNumberFormatException ex
displayMessageEnter a valid input"; ;
GridPane grid new GridPane;
grid.setPaddingnew Insets;
grid.setHgap;
grid.setVgap;
grid.addtext;
forint i dig ; i ; i
forint k ; k ; k dig
grid.adddigitdigki;
grid.adddigit;
grid.addenter;
Scene s new Scenegrid;
primarystage.setScenes;
primarystage.show;
atm new ATMtext;
private void displayMessageString msg
text.appendTextmsg
;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started