Partial coding for the ui bank account application

import javax.swing.JFrame;

/**
A GUI for manipulating a bank account.
*/
public class BankAccountViewer
{
private static final double INITIAL_BALANCE = 1000;

public static void main(String[] args)
{
BankAccount account = new BankAccount(INITIAL_BALANCE);

// construct the frame
JFrame frame = new BankAccountFrame(account);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}

___________________

/**
A bank account has a balance that can be changed by
deposits and withdrawals.
*/
public class BankAccount implements Comparable<BankAccount>
{
private double balance;

/**
Constructs a bank account with a zero balance.
*/
public BankAccount()
{
balance = 0;
}

/**
Constructs a bank account with a given balance.
@param initialBalance the initial balance
*/
public BankAccount(double initialBalance)
{
balance = initialBalance;
}

/**
Deposits money into the bank account.
@param amount the amount to deposit
*/
public void deposit(double amount)
{
double newBalance = balance + amount;
balance = newBalance;
}

/**
Withdraws money from the bank account.
@param amount the amount to withdraw
*/
public void withdraw(double amount)
{
double newBalance = balance - amount;
balance = newBalance;
}

/**
Gets the current balance of the bank account.
@return the current balance
*/
public double getBalance()
{
return balance;
}

public int compareTo(BankAccount other)
{
double d = balance - other.balance;
if (d < 0)
return -1;
if (d > 0)
return 1;
return 0;
}
}

___________________________

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
A frame for manipulating a bank account.
*/
public class BankAccountFrame extends JFrame
{
private BankAccount account;
private JLabel label;
private JTextField amountField;

private static final int FRAME_WIDTH = 400;
private static final int FRAME_HEIGHT = 100;

/**
Constructs a BankAccountFrame for a given account.
@param anAccount the account to manipulate
*/
public BankAccountFrame(BankAccount anAccount)
{
account = anAccount;

// The label for displaying the results
label = new JLabel("balance=" + account.getBalance());

// the label, text field, and button for entering an amount
JLabel amountLabel = new JLabel("Amount:");
amountField = new JTextField(7);

// the control panel that holds the components
JPanel controlPanel = new JPanel();
controlPanel.add(amountLabel);
__________________________________
controlPanel.add(createWithdrawButton());
__________________________________
controlPanel.add(label);

add(controlPanel);
setSize(FRAME_WIDTH, FRAME_HEIGHT);
}

private JButton createDepositButton()
{
JButton depositButton = new JButton("Deposit");

class DepositListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
double depositAmount = Double.parseDouble(________________________________);

account._________________________________________
label.setText("balance=" + __________________________________));
}
}

ActionListener listener1 = new DepositListener();
depositButton.addActionListener(listener1);
return depositButton;
}

private JButton createWithdrawButton()
{
JButton withdrawButton = new JButton("Withdraw");

class WithdrawListener implements ActionListener
{
    YOUR CODE
}
}

___________________________________
___________________________________
return withdrawButton;
}
}



Grading