Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I already have the necessary classes that draw the ATM and Banker data fields, i

ID: 3625520 • Letter: I

Question

I already have the necessary classes that draw the ATM and Banker data fields, i just need help with adding the following interactions:

I need to add the following to some GUI classes already put together. The Banker and ATM GUI classes will need a new data field that refers to the AccountManager. The constructor for each of these classes will need a new parameter that is the reference to the AccountManager and then pass it to the Banker and ATM GUI constructors.

Add necessary button listeners to the GUI classes. Each button listener will need to call the appropriate methods/constructors in the AccountManager and Account classes. Add code to the button listeners to catch the Exceptions that the AccountManager and Account methods may throw. The button listeners also need to catch NumberFormatExceptions wherever a number is supposed to be by the user.

The code should allow the following interactions:

Banker GUI

1) Using the Banker GUI, one can enter a name and press the Open Account Button. The GUI will then create the Account and display the assigned ID for the Account. If there is an error, a message will be displayed in a dialog box. Once an Account has been opened, it is available for use at the ATM GUI.

2) Using the Banker GUI, one can enter an ID and press the Close Account Button. A message will be displayed in a dialog box. Once an Account has been closed, it is no longer available for use at the ATM GUI.

ATM GUI

1) A user may enter their ID and press the Balance button. The balance in the account will be displayed in the Amount field. If there is an error, a message will be displayed in the message textfield at the bottom of the GUI.

2) A user may enter their ID and an amount and then press the Deposit button. An appropriate message will be displayed in the message textfield at the bottom of the GUI.

Explanation / Answer

CLASS1: import java.awt.*; import javax.swing.*; public class DrawLogo extends Panel { JPanel panel1 = new JPanel(); DrawLogo() { // Create a frame JFrame myFrame1 = new JFrame(); // Add a component with a custom paint method myFrame1.getContentPane().add(new drawLogo()); // Display the frame int frameWidth = 400; int frameHeight = 300; myFrame1.setSize(frameWidth, frameHeight); myFrame1.setVisible(true); } class drawLogo extends JPanel { public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; // Draw an oval that fills the window //1 g.drawLine(21, 52, 49, 140); g.drawLine(26, 52, 55, 140); // 2 g.drawLine(49, 140, 75, 94); g.drawLine(55, 140, 80, 94); // 3 g.drawLine(75, 94, 101, 140); g.drawLine(80, 94, 106, 140); // 4 g.drawLine(101, 140, 132, 52); g.drawLine(106, 140, 138, 52); // b g.drawLine(160, 50, 160, 140); g.drawLine(156, 50, 156, 140); //g2d.drawOval(163, 49, 50, 50); g.drawArc(130, 49, 65, 45, 90, -180); g.drawArc(130, 95, 65, 45, 90, -180); g.drawArc(135, 49, 65, 45, 90, -180); g.drawArc(135, 95, 65, 45, 90, -180); g.drawLine(240, 50, 240, 140); g.drawLine(236, 50, 236, 140); //g2d.drawOval(163, 49, 50, 50); g.drawArc(208, 49, 65, 45, 90, -180); g.drawArc(208, 95, 65, 45, 90, -180); g.drawArc(213, 49, 65, 45, 90, -180); g.drawArc(213, 95, 65, 45, 90, -180); Font myFont = new Font("arail", Font.BOLD, 34); g.setFont(myFont); g.drawString("Worlds Best Bank", 20,200); } } } CLASS2 import java.awt.Color; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingConstants; public class ATM_GUI { JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); JPanel panel5 = new JPanel(); JLabel text = new JLabel("Amount:", SwingConstants.CENTER); JTextField dataEntry = new JTextField(10); JButton aButton = new JButton("Deposit"); JLabel text2 = new JLabel("ID:", SwingConstants.CENTER); JTextField dataEntry2 = new JTextField(10); JButton aButton2 = new JButton("Withdraw"); JButton aButton3 = new JButton("Balance"); JTextField dataEntry3 = new JTextField(20); DrawLogo drawing = new DrawLogo(); public ATM_GUI() { JFrame myFrame = new JFrame(); myFrame.setSize(600, 600); myFrame.setLocationRelativeTo(null); myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); myFrame.setTitle("ATM Interface"); myFrame.setBackground(Color.yellow); myFrame.setLayout(new GridLayout(3, 1)); // place fields onto frame myFrame.add(panel1); panel1.add(text2); panel1.add(dataEntry); panel1.add(text); panel1.add(dataEntry2); myFrame.add(panel2); panel2.add(aButton); panel2.add(aButton3); panel2.add(aButton2); myFrame.add(panel5); panel5.add(drawing); myFrame.setVisible(true); } } CLASS3 import java.awt.*; import javax.swing.*; public class Banker extends JComponent { JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); JPanel panel3 = new JPanel(); JLabel text = new JLabel("ID:", SwingConstants.CENTER); JTextField dataEntry = new JTextField(10); JButton aButton = new JButton("Open Account"); JLabel text2 = new JLabel("Name:", SwingConstants.CENTER); JTextField dataEntry2 = new JTextField(10); JButton aButton2 = new JButton("Close Account"); JButton aButton3 = new JButton("Close Account"); DrawLogo drawing = new DrawLogo(); public Banker(){ JFrame myFrame = new JFrame(); myFrame.setSize(600,600); myFrame.setLocationRelativeTo(null); myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); myFrame.setTitle("Open/Close Bank Account Interface"); myFrame.setBackground(Color.yellow); myFrame.setLayout(new GridLayout(4,1)); //place fields onto frame myFrame.add(panel1); panel1.add(text2); panel1.add(dataEntry); panel1.add(text); panel1.add(dataEntry2); myFrame.add(panel2); panel2.add(aButton); panel2.add(aButton2); panel2.add(aButton2); myFrame.add(panel3); //panel3.add(drawing); myFrame.setVisible(true); } } CLASS4 public class MainProgram { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub new ATM_GUI(); new Banker(); //new DrawLogo(); } }