Can someone help me convert the following java code which is in a GUI format into a text based interface?
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
import java.io.IOException;
import java.util.Scanner;
public class BankAccount {
private double balance;
public BankAccount(){
double initialBalance = 0;
}
public BankAccount (double initialBalance){
balance = initialBalance;
}
public void deposit(double amount){
balance = balance + amount;
}
public void withdraw(double amount){
balance = balance - amount;
}
public double getBalance(){
return balance;
}
public class Customer {
private int customerNumber;
private int pin;
private BankAccount checkingAccount;
private BankAccount savingsAccount;
public Customer(int aNumber, int aPin)
{
customerNumber = aNumber;
pin = aPin;
checkingAccount = new BankAccount();
savingsAccount = new BankAccount();
}
public boolean match(int aNumber, int aPin)
{
return customerNumber == aNumber && pin == aPin;
}
public BankAccount getCheckingAccount()
{
return checkingAccount;
}
public BankAccount getSavingsAccount()
{
return savingsAccount; } }
public class Bank {
private ArrayList<Customer> customers;
public Bank()
{
customers = new ArrayList<Customer>();
}
public void readCustomers(String filename)
throws IOException
{
Scanner in = new Scanner(new File(filename));
while (in.hasNext())
{
int number = in.nextInt();
int pin = in.nextInt();
Customer h = new Customer(number, pin);
addCustomer(h);
}
in.close();
}
public void addCustomer(Customer h)
{
customers.add(h);
}
public Customer findCustomer(int aNumber, int aPin)
{
for (Customer h : customers)
{ if (h.match(aNumber, aPin))
return h;
}
return null; } }
public class ATM {
public static final int CHECKING_ACCOUNT = 1;
public static final int SAVINGS_ACCOUNT = 2;
private int state;
private int customerNumber;
private Customer currentCustomer;
private BankAccount currentAccount;
private Bank theBank;
public static final int START = 1;
public static final int PIN = 2;
public static final int ACCOUNT = 3;
public static final int TRANSACTION = 4;
public ATM(Bank aBank){
theBank = aBank;
reset();
}
public void reset(){
customerNumber = 1;
currentAccount = null;
state = START;
} public void setCustomerNumber(int number){
assert state == START;
customerNumber = number;
state = PIN;
}
public void selectCustomer(int pin){
assert state == PIN;
currentCustomer = theBank.findCustomer(customerNumber, pin);
if(currentCustomer == null){
state = START;
}else{
state = ACCOUNT;
} }
public void selectAnAccount(int account){
assert state == ACCOUNT || state == TRANSACTION;
if(account == CHECKING_ACCOUNT){
currentAccount = currentCustomer.getCheckingAccount();
}else{
currentAccount = currentCustomer.getSavingsAccount();
}
state = TRANSACTION;
}
public void withdraw(double amount){
assert state == TRANSACTION;
currentAccount.withdraw(amount);
}
public void deposit(double amount){
assert state == TRANSACTION;
currentAccount.deposit(amount);
}
public void back(){
if(state == TRANSACTION){
state = ACCOUNT;
}else if(state == ACCOUNT){
state = PIN;
}else if(state == PIN){
state = START;
} }
public int getState(){
return state;
}
public double getBalance(){
assert state == TRANSACTION;
return currentAccount.getBalance();
} }
//public static class ATMTester {
public void main(String[] args) {
ATM myATM;
try {
Bank xBank = new Bank();
xBank.readCustomers("The_X_Bank.txt");
myATM = new ATM(xBank);
} catch (IOException e) {
System.out.println("error in customer's file");
return;
}
Scanner input = new Scanner(System.in);
while (true) {
int state = myATM.getState();
if (state == ATM.START) {
System.out.print("Enter customer number: ");
int number = input.nextInt();
myATM.setCustomerNumber(number);
} else if (state == ATM.PIN) {
int pin = input.nextInt();
myATM.selectCustomer(pin);
} else if (state == ATM.ACCOUNT) {
System.out.print("A=Checking, B=Savings, C=Quit: ");
String command = input.next();
if (command.equalsIgnoreCase("A")) {
myATM.selectAnAccount(ATM.CHECKING_ACCOUNT);
} else if (command.equalsIgnoreCase("B")) {
myATM.selectAnAccount(ATM.SAVINGS_ACCOUNT);
} else if (command.equalsIgnoreCase("C")) {
myATM.reset();
} else {
System.out.println("Illegal input!");
} } else if (state == ATM.TRANSACTION) {
System.out.println("Balance=" + myATM.getBalance());
System.out.print("A=Deposit, B=Withdrawal, C=Cancel: ");
String command = input.next();
if (command.equalsIgnoreCase("A")) {
System.out.print("Amount: ");
double amount = input.nextDouble();
myATM.deposit(amount);
myATM.back();
} else if (command.equalsIgnoreCase("B")) {
System.out.print("Amount: ");
double amount = input.nextDouble();
myATM.withdraw(amount);
myATM.back();
} else if (command.equalsIgnoreCase("C")) {
myATM.back();
} else {
System.out.println("illegal input");
}
}
}
}
}