Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the BankPanel.java class as shown below. This class creates a GUI for a BankAccount object.. Show the BankAccount objects account name, number, balance and

Implement the BankPanel.java class as shown below. This class creates a GUI for a BankAccount object.. Show the BankAccount objects account name, number, balance and status. The user enters a Deposit/.Withdraw amount (a nice number) and clicks on either the Deposit or Withdraw button. The new balance is displayed. The status field displays Overdrawn if the balance is negative, otherwise displays OK.

2. Use the BankAccount.java and the BankGUI.java classes provided.

package ch6BankAccountGUI;

class BankAccount {

private int acctNumber; private double balance; private String name;

private static int acctCount= 0; //not an instance variable, but a class variable (static)

/** constructs a bank account with zero balance, zero account number and name set to Unknown

*/

public BankAccount() { acctNumber = 0; balance = 0.0; name = "Unknown";

acctCount++; }

/* constructs a bank account with an account number, an initial balance, and an owner! */

public BankAccount(int acctNo, double initBalance, String owner) { acctNumber = acctNo; balance = initBalance; name = owner;

acctCount++; }

//all of the mutator methods - set

public void setAcctNumber(int acct) { acctNumber = acct; }

public void setBalance(double amount) { balance = amount; }

public void setName(String someName) { name = someName; }

//all of the accessor methods - get

public int getAcctNumber() { return acctNumber; }

public double getBalance() { return balance; }

public String getName() { return name; }

public void deposit(double amount) { balance = balance + amount; }

public void withdraw(double amount) { balance = balance - amount; } //overloaded method. charges a fee! public void withdraw(double amount, double fee) { balance = balance - amount - fee; }

public String toString() { return ("BankAccount : acctNumber " + acctNumber + " balance : " + balance + " name : " + name ); }

//Class method to display our private static variable public static int getAcctCount() { return ( acctCount ); } }// end of class definition

package ch6BankAccountGUI;

import javax.swing.JFrame;

public class BankGUI { //----------------------------------------------------------------- // Creates and displays the main program frame. //----------------------------------------------------------------- public static void main (String[] args) { JFrame frame = new JFrame ("My Bank Account"); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

BankPanel panel = new BankPanel(); frame.getContentPane().add(panel);

frame.pack(); frame.setVisible(true); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions

Question

=+a) Create an appropriate display of these data. What do you see?

Answered: 1 week ago

Question

Explain the causes of indiscipline.

Answered: 1 week ago