I am having some issues once again with programming. I want to learn this stuff and have read and reread the materials but I am misfiring somewhere. Here is the code that I have written so far:
public class Week01 { ArrayList<Customer> mycustomer; final ArrayList<Employee> myemployee = new ArrayList<Employee>(); private JFrame frame; private JTextField tfgiven; private JTextField tflast; private JTextField tfpersonID; private JTextField tfphone; private JTextField tfaddress; private JTextField tfcity; private JTextField tfstate; private JTextField tfzip; private JTextField tfzip4; private JButton btnAddCustomer; private JButton btnAddEmployee; private JButton btnDisplayAll; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Week01 window = new Week01(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the application. */ public Week01() { initialize(); } /** * Initialize the contents of the frame. */ private void initialize() { There is a bunch of code in here.... btnAddCustomer.addActionListener(new CustomerListener()); btnAddEmployee.addActionListener(new EmployeeListener()); btnDisplayAll.addActionListener(new DisplayAllListener()); tfgiven.addActionListener(null); tflast.addActionListener(null); tfpersonID.addActionListener(null); tfaddress.addActionListener(null); tfcity.addActionListener(null); tfstate.addActionListener(null); tfzip.addActionListener(null); tfzip4.addActionListener(null); } private class CustomerListener implements ActionListener { public void actionPerformed(ActionEvent e) { if(e.getSource() == btnAddCustomer) { String givenName = tfgiven.getText(); tfgiven.setText(""); String surname = tflast.getText(); tflast.setText(""); String customerID = tfpersonID.getText(); tfpersonID.setText(""); if(customerID.trim().equals("")) { JOptionPane.showMessageDialog(null, "Customer ID required."); } else { Integer.parseInt(customerID); String phoneNumber = tfphone.getText(); tfphone.setText(""); String streetAddress = tfaddress.getText(); tfaddress.setText(""); String city = tfcity.getText(); tfcity.setText(""); String state = tfstate.getText(); tfstate.setText(state); String zip = tfzip.getText(); tfzip.setText(""); if(zip.trim().equals("")) { return; } else { Integer.parseInt(zip); } String zipPlus4 = tfzip4.getText(); tfzip4.setText(""); if(zipPlus4.trim().equals("")) { return; } else { Integer.parseInt(zipPlus4); } } return; } } } private class EmployeeListener implements ActionListener { public void actionPerformed(ActionEvent e) { if(e.getSource() == btnAddEmployee) { String givenName = tfgiven.getText(); String surname = tflast.getText(); String employeeID = tfpersonID.getText(); if(employeeID.trim().equals("")) { JOptionPane.showMessageDialog(null, "Employee ID required."); } else { Integer.parseInt(employeeID); String phoneNumber = tfphone.getText(); String streetAddress = tfaddress.getText(); String city = tfcity.getText(); String state = tfstate.getText(); String zip = tfzip.getText(); if(zip.trim().equals("")) { } else { Integer.parseInt(zip); } String zipPlus4 = tfzip4.getText(); if(zipPlus4.trim().equals("")) { } else { Integer.parseInt(zipPlus4); } Employee employees = new Employee(null, null, false, 0); myemployee.add(employees); } } } } private class DisplayAllListener implements ActionListener { public void actionPerformed(ActionEvent e) { if(e.getSource() == btnDisplayAll) { for(int i = 0; i < mycustomer.size(); i++) { mycustomer.get(i).getGivenName(); mycustomer.get(i).getsurname(); mycustomer.get(i).getCustomerID(); mycustomer.get(i).getPhoneNumber(); mycustomer.get(i).getStreetAddress(); mycustomer.get(i).getState(); mycustomer.get(i).getZip(); mycustomer.get(i).getZipPlus4(); } ArrayList<ArrayList<Customer>> mycustomer = new ArrayList<ArrayList<Customer>>(); mycustomer.add(new ArrayList<Customer>()); mycustomer.get(0).add(null); for(int j = 0; j < myemployee.size(); j++) { myemployee.get(j).getGivenName(); myemployee.get(j).getsurname(); myemployee.get(j).getEmployeeID(); myemployee.get(j).getPhoneNumber(); myemployee.get(j).getStreetAddress(); myemployee.get(j).getCity(); myemployee.get(j).getState(); myemployee.get(j).getZip(); myemployee.get(j).getZipPlus4(); } myemployee.toArray(); } System.out.println("Customers: " + "\n" + mycustomer + "\nEmployees: " + "\n" + myemployee); } } }
So I have a Person class that holds the first and last name, phone number, address, city, state, zip; I have a Customer class (first name, last name, customer ID) and an Employee class (first name, last name, employee ID). When I press the ADD CUSTOMER button and then the DISPLAY ALL button I am not getting what I input in the textfields. Yes I am new to this, yes I ask stupid questions, no I am not understanding all this.