Sie sind auf Seite 1von 112

IB Program Dossier

Table of Contents
IB Program Dossier............................................................................................................. 1 Table of Contents................................................................................................................ 2 Stage A Analysis.............................................................................................................. 3 Criteria A1: Analyzing the problem ........................................................................... 4-5 Criteria A2: Criteria for success ................................................................................. 6-7 Criteria A3: Prototype solution................................................................................. 8-13 Stage B Detailed design ................................................................................................. 14 Criteria B1: Data structures .................................................................................... 15-17 Criteria B2: Algorithms .......................................................................................... 18-19 Criteria B3: Modular organization.......................................................................... 20-21 Stage C The program ..................................................................................................... 23 Criteria C1: Using good programming style........................................................... 24-90 Criteria C2: Handling errors ................................................................................... 91-95 Criteria C3: Success of the program...96-97 Stage D Documentation ................................................................................................. 98 Criteria D1: Including an annotated hard copy of the test output......................... 99-107 Criteria D2: Evaluating solutions........................................................................ 109-111 Documentation of Mastery items.................................................................................... 112

Stage A Analysis

Criteria A1: Analyzing the problem

Statement of the problem and analysis:


How can the average American household keep track of the electric bill (as a house hold total and as individual or groups of electronics; EX:. A single light bulb or an entire entertainment system). An example of household electricity usage is shown bellow:

This is just a simple electricity calculator for a single electronic. This program is limited greatly by the fact that it only computes a single set item (item has to be selected from a list, limited to the list) of the household and does not retain data in its system. Additionally the time used/on per day and the electricity cost also have to be selected from a list. Since the discovery of electricity, the totaling of electric bills has become commonplace; yet usually done by electric companies. Online there exists many electricity calculators like the one above, but they are all limited by the fact that they are all essentially the same program computing the same thing with the same limitations. I have found it impossible to find a program that will keep track of all of a households electronics. All the calculators calculate single items making it very hard for the user to get an idea of his/her total electric bill. Knowing this I figured

that all households in the U.S. could use something like this to estimate or even determine their monthly electricity bill if I choose to share it. The household electronic bill is almost completely based on calculations and so with a properly made program the electricity bill can be quickly and easily calculated, with minimal user input. The program can additionally be modified to bring data to the user that the program finds to be irregularly high/low in hopes of checking user error. As stated earlier other electricity calculating programs I have seen are severally limited to small calculations, from set lists, and only calculate the electricity usage of single appliance only a month or year into the future. My program will ask for time periods to calculate the electricity bill, whether it be a second or a year. My program will also store data entered by the user into a saved database, allowing the user to not have to manually type in information every time the program is used.

Criteria A2: Criteria for success


The testing system: What the program will do: The program will be tested using data from appliances in my users house with my user using the program. He will first go to Add/Edit New Appliance and input data relating appliance names, the number of appliances in the house, how much electricity the appliance uses while on and off (phantom energy use), and the time the appliance is used per day. Next the user will exit out of the new appliance window and then click on the Cost of Electricity button where he will input the current cost of electricity. He will then exit that window and click on the Calculate bill and electricity use button; where he will then input the number of appliances he wishes to calculate, what appliances he wishes to calculate, and the time at which the bill will be calculated for. After imputing the data he will finally use the calculate button to find the electricity used and the amount of money it will cost. Additionally thorough this process if the user does not understand how to use the program on each window is a helpful Help button, that when pressed displays a help window listing different areas of the program that the user could be confused about. In the testing system the user must give: The current cost of electricity The appliances that are used in his/her house -name -number of that appliance in the household -electricity use -time used daily -time plugged in -phantom electricity use The time he/she wishes to calculate the bill from The number of appliances he/she wishes to calculate The appliances the user wishes to calculate The system will calculate: The amount of electricity used by the specified appliances in Watts The amount of money the electricity will cost him/her The system will also additionally store all user given information, not the calculations, in a library folder where the information will be stored for easy user access next time the program is used.

User controls: The user may: Add or edit data on appliances -name -number of that appliance in the household -electricity use -time used daily -time plugged in -phantom electricity use Change the price of electricity Select different times from which the bill is calculated Choose what appliances are calculated in the bill and electricity total

Criteria A3: Prototype solution

Welcome Page Welcomes user to program

Electronic Devices Lists houses electronic devices and allows user to add or change these devices.

Main Menu Where user can choose to go to Electronic Devices or go to calculate the power-usage and electricity bill.

Calculate Power-usage and electricity bill Allows the user to choose the appliances power usage and power cost for a certain period of time.

Help Menu Where the user goes when he or she is confused by the program and needs help to figuring it out.

Electricity Cost Where the user inputs the current cost of electricity.

The Main Page: Description: Holds no data and processes nothing. Only used by the user to navigate to forms that can create, calculate, and store data

Help Form: Description: In this page the user can obtain info about different parts of the program from a list that displays different parts of the program the user can obtain data that is displayed in a textbox.

Adding/Changing Electronics: Description: Allows the user to add an electronic to the household list index, or to change an electronics data from the household list index. Contains a List box, as well as a series of text fields, combo boxes and buttons.

The Calculate Form: Description: This part of the program allows the user to select parts of the electronics list, and based on the cost of electricity and time used, calculate how much electricity is used and as well how much the electricity used will cost (without tax). This page features a combo box which takes in the number of electronics, a list of the appliances, as well as various text boxes and buttons which allow the user to select more information and for information to be displayed.

Cost of electricity:
Appears when the user selects the Cost of Electricity button on the calculate page.

User Feedback:
When interviewed about the programs prototype the user made comments expressing some concerns with the program such as: The program is to confusing to use. It needs to be easier to use Which is when the help page was created to help guide the user through the use of the program. The program requires too much work to be used the user shouldnt have to manually type in the information for each item, its too much work. Thus the idea came about for a combo box to be added to the add page in a latter version of the program. The user would select and item from the combo box and the data for the selected item would fill out the appropriate information; if the information differed from what was set the user would simply change the data in error. What if multiple users wish to use the program? Do they all have to share? To answer this a login page, or something similar, will be created in the future and added to the program to allow for multiple users. All these changes will be made in an updated version as more time is spent working on the program. After changes are made the user will tryout the program and another Q&A session will begin.

Stage B Detailed design

Criteria B1: Data structures

Storing data for electronics: Initially I thought to use a primary index, to store all the electronics and their respective data. In this index data would be separated by lines and commas by the use of a read and write file. So for example, (as in the diagram below) The electronic, TV would be used 5 hours a day, be plugged in always, use 150 Watts an hour on, and have the phantom electricity use of 5 watts an hour(if the user does not know the phantom energy use then the user leaves that field blank and when the user checks if the electronics make/model is before or after 2007, which allows the program to add data for the phantom energy use due to new U.S. regulations as of 2007 requiring all new electronics to have a phantom energy use of 0.5 Watts). Another index would store electronics in the users household and would be used as the users electronics. This way in each line of the primary index there is the whole data of the whole electronic appliance that can be selected and upon clicking the Add/Change button the user would add an electronic to his/her household electronic list. This list being selected from the earlier Jframe form Electronics Lists. Another Idea I am working with is to use an array list to keep all my data in order. Similar to the primary index idea it would also store all the electronics and their respective data. So once again this idea would also be ,for example, (similar the diagram below) The electronic, TV would be used 5 hours a day, be plugged in always, use 150 Watts an hour on, as well as the phantom electricity usage.

Primary List Index Example: TV,5hours,24hours,150Watts,5Watts,3,Before 2007 Compact Fluorescents (CFLs),2hours,24hours,105Watts,,8,After 2007 X-Box 360,6hours,24hours,206Watts,,1,After2007 Electronics from the Primary Index, like the ones above, can be selected from the pull down from the Combo Box which will quickly fill in the information below allowing the electronic to be quickly be added to the current electronics list. The index is set so that for example, the TV above is the electronics name, the 5hours is the time used a day, the 24hours is the time plugged in, the 150Watts is the power usage while in use, the 5Watts is the standby power usage, the 3 is the number of TVs the users house has, and that Before 2007 indicates that the standby power usage is likely to be greater than the 0.5 Watts required in new electronics.

This solution is a very good one and fairly easily implemented. This method allows for the quick exchange of data between indexes, using a series of read methods, and is very efficient due to the fact that the electronics are ordered alphabetically. Because the user looks for a specific electronic the use of the Combo Box may take time to find a specific electronic or the electronic might not be listed in the Primary Index; in these cases there are text fields that can get data from the user. The series of text fields and checkbox allows for user input into the indexes using a series of write methods to write the data imputed onto the users list, which will be described in more detail in B2. File Structure: Field Electronic Time Used Time Plugged in Electricity Used Phantom Energy Used Quantity Before 2007 Data Type String Double Double Integer Integer Integer Boolean (True/False)

To delete an entry the user simply clicks on the appliance name in the House Electronics list and then clicks the remove button. This removes the electronic from the users list and all the data is then shuffled forward one to fill in the empty space left in the list. Main Page: This page holds none of the many variables of the program but is simply a way to access the other pages of the program. Adding/ChangingElectronics: On this page all the variables in the File Structure are in effect. On this page the user fills out text fields to create values for these variables. These variables are kept in order via the ArrayList household and the Class Object Household. Help: On this page information is kept in order by an ArrayList similar to the one in Adding/ChangingElectronics. This ArrayList ,Help, keeps variables in accordance to the different sections of the program; such as Main Menu, Adding Electronics, Calculating the Electricity Used, ext. Calculate:

On this page the variables for electronics created on the Adding/ChangingElectronics page are used to calculate the amount of electricity used as well as the cost of the electricity. Household: This Class Object holds all the key variables of the program, mostly the variables shown in B1s File Structure.

Criteria B2: Algorithms


Algorithm 1: The Main Page Actions: User can use a series of buttons to go to the Adding/ChangingElectronics page, the Calculate page, as well as exit the program. This occurs using the set visible method. When clicked these buttons reveal the selected form while closing the current window. Algorithm 2: Adding/ChangingElectronics Actions: Contains a List box, and buttons. The list box displays different applications to the user who can select electronics and have their values displayed on the appropriate text fields and combo boxes. There is an Add/Edit button that saves the electronics data to the electronic in the list as well as a Remove button, which will delete the selected appliance from the list box. The Help button brings up the help screen as described below. Finally, there is an Exit button that exits out of the program. Algorithm 3: Help: Actions: On this page exists a list box that allows information (like the variables listed in Section B1 under Help) about the various parts of the program to be stored. Upon being selected information appears in a textbox. Of the buttons there the Main Menu button takes the user back to the main menu screen, while the Exit button quickly takes the user out of the program. Algorithm 4: Calculate: Actions: In this part of the program the user first uses the combo box to select the number of electronics that he/she wishes to calculate electricity usage and electricity cost. The user then uses the list box the select the electronics the user wishes to calculate from (a jOptionPane will appear if the number of electronics selected in the combo boxes and the appliance list box do not match). The user next selects the electricity cost button and insets the cost of electricity in his/her area per watt. Finally the user can click on the Calculate button which will take the data the user has selected and display the energy used as well as the cost of the electricity in the appropriate text fields. The user can also at any time click on the Clear button and reset the page to its natural settings or the exit button which will exit the user out of the program. Algorithm 5: Household Description: This is a class object used by the main forms Add/Edit and Calculate. Hold variables for the entire application as well as its constructors. Actions: Contains the get and set methods for the entire program. For each variable in the program this class object there is a set and get method in this. Additionally this class

object contains an empty constructor and another constructor which holds all the variables as well as the shorthand for each variable (the constructors link the class object to the main UI forms). Algorithm 6: Read File Description: Reads data from the text file attached to the program, where all the data for the variables are stored. Uses ,s to separate variable information. Algorithm 7: Write File Description: Writes data from the program into the text file attached to the program. Allows info to be taken from various text fields and combo boxes and stored.

Criteria B3: Modular organization


Main Menu

Calculate Electricity usage

Household Electronics Lists

Cost of Electricity Time Period Date

New List Edit List Delete List

Calculate Cost and amount of electricity used

Add/Change Electronics Add/Change Electronic Name Add/Change Time Plugged in Add/Change the amount of electricity consumed per hour Add/Change Phantom Energy used Add/Change the number of the electronic in household Add/Change time used on different days of the week or on holidays

From the main menu the user has two choices to select. If he or she already has data in his or her household list than the user can select Calculate Electricity Usage. If the user has not imputed any data into the program the user must go to the Household Lists. Called From: Links To:

Household Lists Main Menu Calculate Electricity Usage

In Household lists the user can create a new list if the user has not created a list to place his/her electronic information into, or create a new list of electronics for a different household. The user can also delete existing lists and edit or add to the by simply selecting a list and having the Add, Remove, or Change electronics screen pop up.

Called From:

Links To:

Household Lists

Add, Remove, or Change electronics

In this the user used a series of text fields, combo boxes and a checkbox to input electronics his/her data into his/her list. This info is then stored in a textfile or the users computer hard drive for later usage in the program. With data now in a household list the user can now go back to the main menu and select the Calculate Electricity Usage button.

Called From:

Links To:

Add, Remove, or Change electronics

Main Menu

In Calculate Electricity Usage the user first inputs the cost of electricity in his/her area from a combo box. The user then selects whither he or she wishes to calculate the electricity cost and usage from a specific time period or a certain day. After selecting wither the user wants to calculate the electricity used on a certain day or time period an appropriate panel will appear corresponding with the users choice. On the appearing panel the user will then be able to input data indicating which day or time period the user wished to calculate from. After imputing that data the simply selects ok and then selects the Calculate button which then takes information from the users selected list and calculates the amount of electricity used and the cost to the user for that day or period of time. Main Page: The main page uses buttons connected the set visible methods that reveal different forms that are associated with the button clicked while closing the main menu at the same time using the dispose method. Adding/ChangingElectronics: This page links all the text fields and combo boxes to the Add button. Upon clicking the Add button all the data in the text fields and combo boxes are stored in a text file and displayed into the electronics list box. Then when an item is in the list box is clicked the data for that selected item appears in the text fields and combo boxes associated with the item. If the item is selected and the Remove button is clicked the Remove.Selectedindex method is used erasing the item. Help: Here the variables in the list box as well as the data associated with the variables are not editable by the user. When the user clicks an item in the list box the data that goes with the variable is made to be displayed in the text field. Calculate: Here the variables are run through code that adds all the electricity used together, displays that amount in the Electricity Used text field, takes that number and multiplies that by the cost of electricity rounded to 2 decimal places and finally displays that amount into the Cost text field. Household: The Household class object takes the variable values of the whole program using getmethods, and then sets the variables value with the setmethod.

Stage C The program

Criteria C1: Using good programming style


Program code:

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * NewBill.java * * Created on Mar 17, 2011, 1:25:23 PM * //By Michael Chun * //Inglemoor Highschool * //at home on a custom built computer, and at school on an old gateway model */ package Electricbill; //imports for the arraylist and the JOptionpane //allows the program to use an arraylist to handle data //as well as the JOptionPane to help display to the user what has gone wrong in the program when a catch statment is used import java.util.ArrayList; import javax.swing.JOptionPane; /** * * @author 1010217 */ public class NewBill extends javax.swing.JFrame { /** Creates new form NewBill */ //array for the whole program, places here to allow array to be global (for the entire program) //holds all data for program and allows access to the Household.java ArrayList<Household> household = new ArrayList<Household>(); public NewBill() { //intitialises the programs components allowing it to run initComponents();

//sets not-visable all parts of the program the programer does not wish the user to initially see holidayLabel1.setVisible(false); numberofholidaysTextField.setVisible(false); Monday.setVisible(false); Tuesday.setVisible(false); Wednesday.setVisible(false); Thursday.setVisible(false); Friday.setVisible(false); Saturday.setVisible(false); Sunday.setVisible(false); Holiday.setVisible(false); newlistPanel.setVisible(false); timePanel.setVisible(false); mondayCheckBox.setVisible(false); tuesdayCheckBox.setVisible(false); wednesdayCheckBox.setVisible(false); thursdayCheckBox.setVisible(false); fridayCheckBox.setVisible(false); saturdayCheckBox.setVisible(false); sundayCheckBox.setVisible(false); //allows the readFiles to be run when the program is first opened householdreadFile(); electronicreadFile(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { newlistPanel = new javax.swing.JPanel(); newlistLabel = new javax.swing.JLabel(); listnameLabel = new javax.swing.JLabel(); listnameTextField = new javax.swing.JTextField(); newlistnameButton = new javax.swing.JButton(); jScrollPane3 = new javax.swing.JScrollPane(); householdList = new javax.swing.JList(); newlistButton = new javax.swing.JButton(); removeButton1 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); electronicsList = new javax.swing.JList();

electronicsLabel = new javax.swing.JLabel(); timeLabel = new javax.swing.JLabel(); electricityusedLabel = new javax.swing.JLabel(); penergyLabel = new javax.swing.JLabel(); timeTextField = new javax.swing.JTextField(); timeComboBox = new javax.swing.JComboBox(); energyTextField = new javax.swing.JTextField(); penergyTextField = new javax.swing.JTextField(); exitButton = new javax.swing.JButton(); electronicTextField = new javax.swing.JTextField(); Monday = new javax.swing.JPanel(); mondayLabel = new javax.swing.JLabel(); mondaytimeLabel = new javax.swing.JLabel(); mondayTextField = new javax.swing.JTextField(); mondayComboBox = new javax.swing.JComboBox(); addmondayButton = new javax.swing.JButton(); Wednesday = new javax.swing.JPanel(); wednesdayLabel = new javax.swing.JLabel(); wednesdaytimeLabel = new javax.swing.JLabel(); wednesdayTextField = new javax.swing.JTextField(); wednesdayComboBox = new javax.swing.JComboBox(); addwednesdayButton = new javax.swing.JButton(); Tuesday = new javax.swing.JPanel(); tuesdayLabel = new javax.swing.JLabel(); tuesdaytimeLabel = new javax.swing.JLabel(); tuesdayTextField = new javax.swing.JTextField(); tuesdayComboBox = new javax.swing.JComboBox(); addtuesdayButton = new javax.swing.JButton(); timePanel = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); startsComboBox = new javax.swing.JComboBox(); jLabel3 = new javax.swing.JLabel(); endsComboBox = new javax.swing.JComboBox(); holidayCheckBox = new javax.swing.JCheckBox(); holidayLabel1 = new javax.swing.JLabel(); numberofholidaysTextField = new javax.swing.JTextField(); costLabel = new javax.swing.JLabel(); costComboBox = new javax.swing.JComboBox(); calculateButton = new javax.swing.JButton(); mondayCheckBox = new javax.swing.JCheckBox(); tuesdayCheckBox = new javax.swing.JCheckBox(); wednesdayCheckBox = new javax.swing.JCheckBox(); thursdayCheckBox = new javax.swing.JCheckBox(); fridayCheckBox = new javax.swing.JCheckBox(); saturdayCheckBox = new javax.swing.JCheckBox(); sundayCheckBox = new javax.swing.JCheckBox();

periodLabel = new javax.swing.JLabel(); periodTextField = new javax.swing.JTextField(); periodComboBox = new javax.swing.JComboBox(); totalLabel = new javax.swing.JLabel(); totalcostTextField = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); totalelectricityTextField = new javax.swing.JTextField(); Thursday = new javax.swing.JPanel(); thursdayLabel = new javax.swing.JLabel(); thursdaytimeLabel = new javax.swing.JLabel(); thursdayTextField = new javax.swing.JTextField(); thrusdayComboBox = new javax.swing.JComboBox(); addthrusdayButton = new javax.swing.JButton(); addButton = new javax.swing.JButton(); removeButton = new javax.swing.JButton(); Madebefore2007CheckBox = new javax.swing.JCheckBox(); quantityLabel = new javax.swing.JLabel(); quantityTextField = new javax.swing.JTextField(); jScrollPane2 = new javax.swing.JScrollPane(); daysList = new javax.swing.JList(); Holiday = new javax.swing.JPanel(); holidayLabel = new javax.swing.JLabel(); holidaytimeLabel = new javax.swing.JLabel(); holidayTextField = new javax.swing.JTextField(); holidayComboBox = new javax.swing.JComboBox(); addholidayButton = new javax.swing.JButton(); Saturday = new javax.swing.JPanel(); saturdayLabel = new javax.swing.JLabel(); saturdaytimeLabel = new javax.swing.JLabel(); saturdayTextField = new javax.swing.JTextField(); saturdayComboBox = new javax.swing.JComboBox(); addsaturdayButton = new javax.swing.JButton(); Friday = new javax.swing.JPanel(); fridayLabel1 = new javax.swing.JLabel(); fridaytimeLabel1 = new javax.swing.JLabel(); fridayTextField1 = new javax.swing.JTextField(); fridayComboBox1 = new javax.swing.JComboBox(); addfridayButton1 = new javax.swing.JButton(); Sunday = new javax.swing.JPanel(); sundayLabel = new javax.swing.JLabel(); sundaytimeLabel = new javax.swing.JLabel(); sundayTextField = new javax.swing.JTextField(); sundayComboBox = new javax.swing.JComboBox(); addsundayButton = new javax.swing.JButton(); helpButton = new javax.swing.JButton(); CalculatesetvisableButton = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); newlistPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); newlistLabel.setText("New List Form"); listnameLabel.setText("List Name:"); newlistnameButton.setText("New List"); newlistnameButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { newlistnameButtonActionPerformed(evt); } }); javax.swing.GroupLayout newlistPanelLayout = new javax.swing.GroupLayout(newlistPanel); newlistPanel.setLayout(newlistPanelLayout); newlistPanelLayout.setHorizontalGroup( newlistPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addGroup(newlistPanelLayout.createSequentialGroup() .addGroup(newlistPanelLayout.createParallelGroup(javax.swing.GroupLayout.Ali gnment.LEADING) .addGroup(newlistPanelLayout.createSequentialGroup() .addGap(32, 32, 32) .addComponent(newlistLabel)) .addGroup(newlistPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(newlistPanelLayout.createParallelGroup(javax.swing.GroupLayout.Ali gnment.LEADING) .addGroup(newlistPanelLayout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(newlistnameButton)) .addGroup(newlistPanelLayout.createSequentialGroup() .addComponent(listnameLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(listnameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE))))) .addContainerGap()) ); newlistPanelLayout.setVerticalGroup( newlistPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addGroup(newlistPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(newlistLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(newlistPanelLayout.createParallelGroup(javax.swing.GroupLayout.Ali gnment.BASELINE) .addComponent(listnameLabel) .addComponent(listnameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(newlistnameButton) .addContainerGap(23, Short.MAX_VALUE)) ); getContentPane().add(newlistPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 30, -1, -1));

householdList.setBorder(javax.swing.BorderFactory.createTitledBorder("Househ old Electronics List")); householdList.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { householdListMouseClicked(evt); } }); householdList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { householdListValueChanged(evt); } }); jScrollPane3.setViewportView(householdList);

getContentPane().add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 20, 260, 140)); newlistButton.setText("New List"); newlistButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { newlistButtonActionPerformed(evt); } }); getContentPane().add(newlistButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 170, -1, -1)); removeButton1.setText("Remove"); removeButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { removeButton1ActionPerformed(evt); } }); getContentPane().add(removeButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 170, -1, -1));

jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder("House Electronics ")); electronicsList.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); electronicsList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { electronicsListValueChanged(evt); } }); jScrollPane1.setViewportView(electronicsList); getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(31, 211, 117, 172)); electronicsLabel.setText("Electronic:"); getContentPane().add(electronicsLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 230, -1, -1)); timeLabel.setText("Time Plugged in:"); getContentPane().add(timeLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 260, -1, -1));

electricityusedLabel.setText("Electricity Used(watts/hour):"); getContentPane().add(electricityusedLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 290, -1, -1)); penergyLabel.setText("Phantom Electricity Used:"); getContentPane().add(penergyLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 320, -1, -1)); timeTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { timeTextFieldActionPerformed(evt); } }); getContentPane().add(timeTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(302, 261, 59, -1)); timeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Milliseconds", "Seconds", "Minutes", "Hours", "All day Long" })); getContentPane().add(timeComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(372, 261, -1, -1)); getContentPane().add(energyTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(372, 291, 61, -1)); getContentPane().add(penergyTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(352, 321, 66, -1)); exitButton.setText("Exit"); exitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exitButtonActionPerformed(evt); } }); getContentPane().add(exitButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(229, 592, -1, -1)); getContentPane().add(electronicTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(292, 231, 72, -1)); Monday.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); Monday.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); mondayLabel.setText("Monday"); Monday.add(mondayLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 128, -1)); mondaytimeLabel.setText("Time Used:");

Monday.add(mondaytimeLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 30, -1, -1)); mondayTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mondayTextFieldActionPerformed(evt); } }); Monday.add(mondayTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 30, 67, -1)); mondayComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Milliseconds", "Seconds", "Minutes", "Hours", "All day Long" })); Monday.add(mondayComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, -1, -1)); addmondayButton.setText("Add"); addmondayButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addmondayButtonActionPerformed(evt); } }); Monday.add(addmondayButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 100, -1, -1)); getContentPane().add(Monday, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 440, 150, 130)); Wednesday.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); wednesdayLabel.setText("Wednesday"); wednesdaytimeLabel.setText("Time Used:"); wednesdayComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Milliseconds", "Seconds", "Minutes", "Hours", "All day Long" })); addwednesdayButton.setText("Add"); addwednesdayButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addwednesdayButtonActionPerformed(evt); } });

javax.swing.GroupLayout WednesdayLayout = new javax.swing.GroupLayout(Wednesday); Wednesday.setLayout(WednesdayLayout); WednesdayLayout.setHorizontalGroup( WednesdayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA DING) .addGroup(WednesdayLayout.createSequentialGroup() .addContainerGap() .addGroup(WednesdayLayout.createParallelGroup(javax.swing.GroupLayout.Ali gnment.LEADING) .addComponent(wednesdayLabel) .addGroup(WednesdayLayout.createSequentialGroup() .addComponent(wednesdaytimeLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(wednesdayTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 41, Short.MAX_VALUE)) .addComponent(wednesdayComboBox, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(addwednesdayButton)) .addContainerGap()) ); WednesdayLayout.setVerticalGroup( WednesdayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA DING) .addGroup(WednesdayLayout.createSequentialGroup() .addContainerGap() .addComponent(wednesdayLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(WednesdayLayout.createParallelGroup(javax.swing.GroupLayout.Ali gnment.BASELINE) .addComponent(wednesdaytimeLabel) .addComponent(wednesdayTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(wednesdayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(addwednesdayButton)) ); getContentPane().add(Wednesday, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 440, -1, -1)); Tuesday.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); tuesdayLabel.setText("Tuesday:"); tuesdaytimeLabel.setText("Time used:"); tuesdayComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Milliseconds", "Seconds", "Minutes", "Hours", "All day Long" })); addtuesdayButton.setText("Add"); addtuesdayButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addtuesdayButtonActionPerformed(evt); } }); javax.swing.GroupLayout TuesdayLayout = new javax.swing.GroupLayout(Tuesday); Tuesday.setLayout(TuesdayLayout); TuesdayLayout.setHorizontalGroup( TuesdayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) .addGroup(TuesdayLayout.createSequentialGroup() .addContainerGap() .addGroup(TuesdayLayout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addComponent(tuesdayLabel) .addGroup(TuesdayLayout.createSequentialGroup()

.addComponent(tuesdaytimeLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(tuesdayTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, TuesdayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) .addComponent(addtuesdayButton) .addComponent(tuesdayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); TuesdayLayout.setVerticalGroup( TuesdayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) .addGroup(TuesdayLayout.createSequentialGroup() .addContainerGap() .addComponent(tuesdayLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(TuesdayLayout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(tuesdaytimeLabel) .addComponent(tuesdayTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(tuesdayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(addtuesdayButton) .addContainerGap(12, Short.MAX_VALUE)) ); getContentPane().add(Tuesday, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 440, -1, -1));

jLabel2.setText("Time Period Starts on a:"); startsComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" })); jLabel3.setText("and ends on a:"); endsComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" })); holidayCheckBox.setText("Time Period includes a holiday"); holidayCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { holidayCheckBoxActionPerformed(evt); } }); holidayLabel1.setText("Number of Holidays included:"); costLabel.setText("Cost of Electricity per KiloWatt($):"); costComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0.00", "0.01", "0.02", "0.03", "0.04", "0.05", "0.06", "0.07", "0.08", "0.09", "0.10", "0.11", "0.12", "0.13", "0.14", "0.15", "0.16", "0.17", "0.18", "0.19", "0.20", "0.21", "0.22", "0.23", "0.24", "0.25", "0.26", "0.27", "0.28", "0.29", "0.30", "0.31", "0.32", "0.33", "0.34", "0.35", "0.36", "0.37", "0.38", "0.39", "0.40", "0.41", "0.42", "0.43", "0.44", "0.45", "0.46", "0.47", "0.48", "0.49", "0.50", "0.51", "0.52", "0.53", "0.54", "0.55", "0.56", "0.57", "0.58", "0.59", "0.60", "0.61", "0.62", "0.63", "0.64", "0.65", "0.66", "0.67", "0.68", "0.69", "0.70", "0.71", "0.72", "0.73", "0.74", "0.75", "0.76", "0.77", "0.78", "0.79", "0.80", "0.81", "0.82", "0.83", "0.84", "0.85", "0.86", "0.87", "0.88", "0.89", "0.90", "0.91", "0.92", "0.93", "0.94", "0.95", "0.96", "0.97", "0.98", "0.99", "1.00" })); calculateButton.setText("Calculate"); calculateButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { calculateButtonActionPerformed(evt); } }); mondayCheckBox.setText("Monday"); tuesdayCheckBox.setText("Tuesday");

wednesdayCheckBox.setText("Wednesday"); thursdayCheckBox.setText("Thursday"); fridayCheckBox.setText("Friday"); saturdayCheckBox.setText("Saturday"); sundayCheckBox.setText("Sunday"); periodLabel.setText("Time Period:"); periodComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Minutes", "Hours", "Days" })); totalLabel.setText("Estimated Total Cost:"); jLabel1.setText("Estimated Electricity Used:"); javax.swing.GroupLayout timePanelLayout = new javax.swing.GroupLayout(timePanel); timePanel.setLayout(timePanelLayout); timePanelLayout.setHorizontalGroup( timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(timePanelLayout.createSequentialGroup() .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addGroup(timePanelLayout.createSequentialGroup() .addGap(10, 10, 10) .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addGroup(timePanelLayout.createSequentialGroup() .addComponent(costLabel) .addGap(18, 18, 18) .addComponent(costComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(timePanelLayout.createSequentialGroup() .addGap(10, 10, 10)

.addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addGroup(timePanelLayout.createSequentialGroup() .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(endsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.TRAILING, false) .addGroup(timePanelLayout.createSequentialGroup() .addGap(67, 67, 67) .addComponent(periodTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(periodComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(timePanelLayout.createSequentialGroup() .addComponent(jLabel2) .addGap(18, 18, 18) .addComponent(startsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))))) .addGroup(timePanelLayout.createSequentialGroup() .addContainerGap() .addComponent(periodLabel)) .addGroup(timePanelLayout.createSequentialGroup() .addGap(38, 38, 38) .addComponent(holidayCheckBox)) .addGroup(timePanelLayout.createSequentialGroup() .addGap(93, 93, 93) .addComponent(calculateButton)) .addGroup(timePanelLayout.createSequentialGroup() .addGap(51, 51, 51)

.addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addGroup(timePanelLayout.createSequentialGroup() .addComponent(jLabel1) .addGap(18, 18, 18) .addComponent(totalelectricityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(timePanelLayout.createSequentialGroup() .addComponent(totalLabel) .addGap(5, 5, 5) .addComponent(totalcostTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGroup(timePanelLayout.createSequentialGroup() .addContainerGap() .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addGroup(timePanelLayout.createSequentialGroup() .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addGroup(timePanelLayout.createSequentialGroup() .addComponent(mondayCheckBox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(tuesdayCheckBox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(wednesdayCheckBox)) .addGroup(timePanelLayout.createSequentialGroup() .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addComponent(thursdayCheckBox) .addGroup(timePanelLayout.createSequentialGroup() .addGap(53, 53, 53) .addComponent(fridayCheckBox))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(saturdayCheckBox))) .addGap(15, 15, 15) .addComponent(sundayCheckBox)) .addGroup(timePanelLayout.createSequentialGroup()

.addComponent(holidayLabel1) .addGap(18, 18, 18) .addComponent(numberofholidaysTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE))))) .addContainerGap()) ); timePanelLayout.setVerticalGroup( timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(timePanelLayout.createSequentialGroup() .addContainerGap() .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(costLabel) .addComponent(costComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(jLabel2) .addComponent(startsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(jLabel3) .addComponent(endsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(periodLabel)

.addComponent(periodComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(periodTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(holidayCheckBox) .addGap(7, 7, 7) .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(holidayLabel1) .addComponent(numberofholidaysTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addGroup(timePanelLayout.createSequentialGroup() .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(mondayCheckBox) .addComponent(tuesdayCheckBox) .addComponent(wednesdayCheckBox)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(thursdayCheckBox) .addComponent(fridayCheckBox) .addComponent(saturdayCheckBox))) .addGroup(timePanelLayout.createSequentialGroup() .addGap(12, 12, 12) .addComponent(sundayCheckBox))) .addGap(7, 7, 7)

.addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(totalLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(totalcostTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(jLabel1) .addComponent(totalelectricityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE) .addComponent(calculateButton) .addContainerGap()) ); getContentPane().add(timePanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 210, 310, 320)); Thursday.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); thursdayLabel.setText("Thursday"); thursdaytimeLabel.setText("Time Used:"); thrusdayComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Milliseconds", "Seconds", "Minutes", "Hours", "All day Long" })); addthrusdayButton.setText("Add"); addthrusdayButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addthrusdayButtonActionPerformed(evt); }

}); javax.swing.GroupLayout ThursdayLayout = new javax.swing.GroupLayout(Thursday); Thursday.setLayout(ThursdayLayout); ThursdayLayout.setHorizontalGroup( ThursdayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) .addGroup(ThursdayLayout.createSequentialGroup() .addContainerGap() .addGroup(ThursdayLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addComponent(thursdayLabel) .addGroup(ThursdayLayout.createSequentialGroup() .addComponent(thursdaytimeLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(thursdayTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE)) .addComponent(thrusdayComboBox, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(addthrusdayButton)) .addContainerGap()) ); ThursdayLayout.setVerticalGroup( ThursdayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) .addGroup(ThursdayLayout.createSequentialGroup() .addContainerGap() .addComponent(thursdayLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(ThursdayLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(thursdaytimeLabel) .addComponent(thursdayTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(thrusdayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(addthrusdayButton)) ); getContentPane().add(Thursday, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 440, -1, -1)); addButton.setText("Add/Change"); addButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addButtonActionPerformed(evt); } }); getContentPane().add(addButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(222, 411, -1, -1)); removeButton.setText("Remove"); removeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { removeButtonActionPerformed(evt); } }); getContentPane().add(removeButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(322, 411, -1, -1)); Madebefore2007CheckBox.setText("Made before 2007"); Madebefore2007CheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Madebefore2007CheckBoxActionPerformed(evt); } }); getContentPane().add(Madebefore2007CheckBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 380, -1, -1)); quantityLabel.setText("Quantity:"); getContentPane().add(quantityLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 350, -1, -1));

quantityTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { quantityTextFieldActionPerformed(evt); } }); getContentPane().add(quantityTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(282, 351, 79, -1)); daysList.setBorder(javax.swing.BorderFactory.createTitledBorder("Days:")); daysList.setModel(new javax.swing.AbstractListModel() { String[] strings = { "Monday", "Tuesday", "Wednesday", "Thrusday", "Friday", "Saturday", "Sunday", "Holidays" }; public int getSize() { return strings.length; } public Object getElementAt(int i) { return strings[i]; } }); daysList.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { daysListMouseClicked(evt); } }); jScrollPane2.setViewportView(daysList); getContentPane().add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(41, 401, 104, -1)); Holiday.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); holidayLabel.setText("Holiday"); holidaytimeLabel.setText("Time Used:"); holidayComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Milliseconds", "Seconds", "Minutes", "Hours", "All day Long" })); addholidayButton.setText("Add"); addholidayButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addholidayButtonActionPerformed(evt); } }); javax.swing.GroupLayout HolidayLayout = new javax.swing.GroupLayout(Holiday); Holiday.setLayout(HolidayLayout);

HolidayLayout.setHorizontalGroup( HolidayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(HolidayLayout.createSequentialGroup() .addGroup(HolidayLayout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addGroup(HolidayLayout.createSequentialGroup() .addGap(38, 38, 38) .addComponent(holidayLabel)) .addGroup(HolidayLayout.createSequentialGroup() .addContainerGap() .addComponent(holidaytimeLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(holidayTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE)) .addGroup(HolidayLayout.createSequentialGroup() .addGap(42, 42, 42) .addComponent(addholidayButton))) .addContainerGap()) .addGroup(HolidayLayout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addGroup(HolidayLayout.createSequentialGroup() .addGap(29, 29, 29) .addComponent(holidayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(26, Short.MAX_VALUE))) ); HolidayLayout.setVerticalGroup( HolidayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(HolidayLayout.createSequentialGroup() .addContainerGap() .addComponent(holidayLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(HolidayLayout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(holidaytimeLabel)

.addComponent(holidayTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE) .addComponent(addholidayButton) .addGap(20, 20, 20)) .addGroup(HolidayLayout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addGroup(HolidayLayout.createSequentialGroup() .addGap(54, 54, 54) .addComponent(holidayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(54, Short.MAX_VALUE))) ); getContentPane().add(Holiday, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 440, -1, -1)); Saturday.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); saturdayLabel.setText("Saturday"); saturdaytimeLabel.setText("Time Used:"); saturdayComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Milliseconds", "Seconds", "Minutes", "Hours", "All day Long" })); addsaturdayButton.setText("Add"); addsaturdayButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addsaturdayButtonActionPerformed(evt); } }); javax.swing.GroupLayout SaturdayLayout = new javax.swing.GroupLayout(Saturday); Saturday.setLayout(SaturdayLayout); SaturdayLayout.setHorizontalGroup(

SaturdayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) .addGroup(SaturdayLayout.createSequentialGroup() .addGroup(SaturdayLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addGroup(SaturdayLayout.createSequentialGroup() .addGap(38, 38, 38) .addComponent(saturdayLabel)) .addGroup(SaturdayLayout.createSequentialGroup() .addContainerGap() .addComponent(saturdaytimeLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(saturdayTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)) .addGroup(SaturdayLayout.createSequentialGroup() .addGap(42, 42, 42) .addComponent(addsaturdayButton))) .addContainerGap()) .addGroup(SaturdayLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addGroup(SaturdayLayout.createSequentialGroup() .addGap(29, 29, 29) .addComponent(saturdayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(29, Short.MAX_VALUE))) ); SaturdayLayout.setVerticalGroup( SaturdayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) .addGroup(SaturdayLayout.createSequentialGroup() .addContainerGap() .addComponent(saturdayLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(SaturdayLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(saturdaytimeLabel)

.addComponent(saturdayTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE) .addComponent(addsaturdayButton) .addGap(20, 20, 20)) .addGroup(SaturdayLayout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addGroup(SaturdayLayout.createSequentialGroup() .addGap(54, 54, 54) .addComponent(saturdayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(54, Short.MAX_VALUE))) ); getContentPane().add(Saturday, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 440, -1, -1)); Friday.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); fridayLabel1.setText("Friday"); fridaytimeLabel1.setText("Time Used:"); fridayComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Milliseconds", "Seconds", "Minutes", "Hours", "All day Long" })); addfridayButton1.setText("Add"); addfridayButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addfridayButton1ActionPerformed(evt); } }); javax.swing.GroupLayout FridayLayout = new javax.swing.GroupLayout(Friday); Friday.setLayout(FridayLayout); FridayLayout.setHorizontalGroup(

FridayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING ) .addGroup(FridayLayout.createSequentialGroup() .addGroup(FridayLayout.createParallelGroup(javax.swing.GroupLayout.Alignme nt.LEADING) .addGroup(FridayLayout.createSequentialGroup() .addGap(38, 38, 38) .addComponent(fridayLabel1)) .addGroup(FridayLayout.createSequentialGroup() .addContainerGap() .addComponent(fridaytimeLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(fridayTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)) .addGroup(FridayLayout.createSequentialGroup() .addGap(42, 42, 42) .addComponent(addfridayButton1))) .addContainerGap()) .addGroup(FridayLayout.createParallelGroup(javax.swing.GroupLayout.Alignme nt.LEADING) .addGroup(FridayLayout.createSequentialGroup() .addGap(29, 29, 29) .addComponent(fridayComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(29, Short.MAX_VALUE))) ); FridayLayout.setVerticalGroup( FridayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING ) .addGroup(FridayLayout.createSequentialGroup() .addContainerGap() .addComponent(fridayLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(FridayLayout.createParallelGroup(javax.swing.GroupLayout.Alignme nt.BASELINE) .addComponent(fridaytimeLabel1)

.addComponent(fridayTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE) .addComponent(addfridayButton1) .addGap(20, 20, 20)) .addGroup(FridayLayout.createParallelGroup(javax.swing.GroupLayout.Alignme nt.LEADING) .addGroup(FridayLayout.createSequentialGroup() .addGap(54, 54, 54) .addComponent(fridayComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(54, Short.MAX_VALUE))) ); getContentPane().add(Friday, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 440, -1, -1)); Sunday.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); sundayLabel.setText("Sunday"); sundaytimeLabel.setText("Time Used:"); sundayComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Milliseconds", "Seconds", "Minutes", "Hours", "All day Long" })); addsundayButton.setText("Add"); addsundayButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addsundayButtonActionPerformed(evt); } }); javax.swing.GroupLayout SundayLayout = new javax.swing.GroupLayout(Sunday); Sunday.setLayout(SundayLayout); SundayLayout.setHorizontalGroup(

SundayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(SundayLayout.createSequentialGroup() .addGroup(SundayLayout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addGroup(SundayLayout.createSequentialGroup() .addGap(38, 38, 38) .addComponent(sundayLabel)) .addGroup(SundayLayout.createSequentialGroup() .addContainerGap() .addComponent(sundaytimeLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(sundayTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE)) .addGroup(SundayLayout.createSequentialGroup() .addGap(42, 42, 42) .addComponent(addsundayButton))) .addContainerGap()) .addGroup(SundayLayout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addGroup(SundayLayout.createSequentialGroup() .addGap(29, 29, 29) .addComponent(sundayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(26, Short.MAX_VALUE))) ); SundayLayout.setVerticalGroup( SundayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(SundayLayout.createSequentialGroup() .addContainerGap() .addComponent(sundayLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(SundayLayout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(sundaytimeLabel)

.addComponent(sundayTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE) .addComponent(addsundayButton) .addGap(20, 20, 20)) .addGroup(SundayLayout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addGroup(SundayLayout.createSequentialGroup() .addGap(54, 54, 54) .addComponent(sundayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(54, Short.MAX_VALUE))) ); getContentPane().add(Sunday, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 440, -1, -1)); helpButton.setText("Help"); helpButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { helpButtonActionPerformed(evt); } }); getContentPane().add(helpButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(63, 592, -1, -1)); CalculatesetvisableButton.setText("Calculate"); CalculatesetvisableButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CalculatesetvisableButtonActionPerformed(evt); } }); getContentPane().add(CalculatesetvisableButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(134, 592, -1, -1)); pack(); }// </editor-fold> //allows new lists to be added to the program

private void newlistnameButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //allows user to add/create new lists newlistPanel.setVisible(false); //sets the variable listname as a string String listname; //sets listname = to the user inputed data from the appropriate textfield listname = listnameTextField.getText(); //sets the listname in the Household Array Household e = new Household(); e.setlistname(listname); //adds the listname to the household household.add(e); //runs the displayhousehole to list and the writefile displayHouseholdToList(); householdwriteFile(); //sets the textfield back to a blank field allowing the user to imput more information listnameTextField.setText(""); } private void householdListMouseClicked(java.awt.event.MouseEvent evt) { } //allows the user to see the panel containing the textfield and button to add a new list to the program private void newlistButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //sets the list panel to true, allowing the user to make a new list newlistPanel.setVisible(true); } //reads from textfile information about the program private void householdreadFile() { ReadFile rf = new ReadFile("houselist_1.txt"); String buffer = rf.readRecord(); while(buffer != null){ //splits data with a "," String[] data = buffer.split(","); Household e = new Household();

//sets list data 0 as the listname e.setlistname(data[0]); //adds data to household array household.add(e); buffer = rf.readRecord(); } //closes readfile rf.close(); //runs displayHouseholdToList(), allowing the new dat ato be displayed displayHouseholdToList(); } //allows new data to be written to the program private void householdwriteFile() { //writes data to the houselist_1 textfile WriteFile wf = new WriteFile("houselist_1.txt"); for(int j = 0; j < household.size(); j++) { //allows data to be seperated by a "," String outputData = ","; Household e = household.get(j); outputData = e.getlistname(); //writes the listname wf.write(outputData); } //closes writefile wf.close(); } //allows data about the electronic to be read from the houselist textfile private void electronicreadFile() { ReadFile rf = new ReadFile("houselist_1.txt"); String buffer = rf.readRecord(); while(buffer != null){ //seperates data with "," String[] data = buffer.split(","); Household e = new Household(); //sets data to be read into the program e.setlistname(data[0]); e.settimein(Double.parseDouble(data[1]));

e.settimeunitsin(Integer.parseInt(data[2])); e.setelectricity(Double.parseDouble(data[3])); e.setpenergy(Double.parseDouble(data[4])); e.setquantity(Double.parseDouble(data[5])); e.setMadebefore2007(Boolean.parseBoolean(data[6])); e.setmondaytimeused(Double.parseDouble(data[7])); e.settuesdaytimeused(Double.parseDouble(data[8])); e.setwednesdaytimeused(Double.parseDouble(data[9])); e.setthursdaytimeused(Double.parseDouble(data[10])); e.setfridaytimeused(Double.parseDouble(data[11])); e.setsaturdaytimeused(Double.parseDouble(data[12])); e.setsundaytimeused(Double.parseDouble(data[13])); e.setholidaytimeused(Double.parseDouble(data[14])); e.settimeunitsused(Integer.parseInt(data[15])); e.setmondaytimeunitsused(Integer.parseInt(data[16])); e.settuesdaytimeunitsused(Integer.parseInt(data[17])); e.setwednesdaytimeunitsused(Integer.parseInt(data[18])); e.setthursdaytimeunitsused(Integer.parseInt(data[19])); e.setfridaytimeunitsused(Integer.parseInt(data[20])); e.setsaturdaytimeunitsused(Integer.parseInt(data[21])); e.setsundaytimeunitsused(Integer.parseInt(data[22])); e.setholidaytimeunitsused(Integer.parseInt(data[23])); e.setelectronicname(data[24]); //adds to household household.add(e); buffer = rf.readRecord(); } //closes the program rf.close(); //runs displayElectronicsToList(), so that the electronic is displayed to the list displayElectronicsToList(); } //allows data to be written ot hte houselist textfile private void electronicwriteFile() { WriteFile wf = new WriteFile("houselist_1.txt"); for(int j = 0; j < household.size(); j++) { //seperates data with a "," String outputData = ","; Household e = household.get(j); //writes all the data

outputData = e.getlistname() + "," + e.getelectronicname() + "," + e.gettimein() + "," + e.gettimeunitsin() + "," + e.getelectricity() + "," + e.getpenergy() + "," + e.getquantity() + "," + e.getMadebefore2007() + "," + "," + e.getmondaytimeused() + "," + e.gettuesadytimeused() + "," + e.getwednesdaytimeuesed() + "," + e.getthursdaytimeused() + "," + e.getfridaytimeused() + "," + e.getsaturdaytimeused() + "," + e.getsundaytimeused() + "," + e.getholidaytimeused() + e.getmondaytimeunitsused() + "," + e.gettuesdaytimeunitsused() + "," + e.getwednesdaytimeunitsused() + "," + e.getthursdaytimeunitsused() + "," + e.getfridaytimeunitsused() + "," + e.getsaturdaytimeunitsused() + "," + e.getsundaytimeunitsused() + "," + e.getholidaytimeunitsused(); wf.write(outputData); } //closes the writefile wf.close(); } //removes a list from the houselist private void removeButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //removes a list from data try{ //removes the list household.remove(householdList.getSelectedIndex()); //displays the lists minus the now removed list displayHouseholdToList(); //writes the current list to file householdwriteFile(); //catches the program and informs the user that they must first select a list to remove }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User needs to select an item from list to remove.");} } private void timeTextFieldActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } //creates an exitbutton private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //closes window and program this.dispose(); } private void mondayTextFieldActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here: } //sets the monday panel notvisable private void addmondayButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try{ Monday.setVisible(false); //catchs the program and tells the user that they must go back and enter an approptiate numerical value into the textfield }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User has entered a non-numerical symbol");} } //sets wednesday panel notvisible private void addwednesdayButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try{ Wednesday.setVisible(false); //catchs program, informs user that they entered a non-numerical vale into the textbox }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User has entered a non-numerical symbol");} } //makes the tuesday panel not visable tot he user private void addtuesdayButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try{ Tuesday.setVisible(false); //catchs the program and informs the user that they have entered a nonnumerical value into the textfield }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User has entered a non-numerical symbol");} } //makes the thursday panel not visable to the user private void addthrusdayButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try{ Thursday.setVisible(false); //catches program, informs the user that they have entered an non-numerical value into the textfield }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User has entered a non-numerical symbol");} }

//adds a new electronic to the electronics list private void addButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //variables used in the add button String listname; String electronic; Double pluggedin; int pluggedtimeunits; Double electricityused; Double Quantity; Boolean Madebefore2007; double mondaytimeused; double tuesdaytimeused; double wednesdaytimeused; double thursdaytimeused; double fridaytimeused; double saturdaytimeused; double sundaytimeused; double holidaytimeused; int timeunitsused; int holidaytimeunitsused; int mondaytimeunitsused; int tuesdaytimeunitsused; int wednesdaytimeunitsused; int thursdaytimeunitsused; int fridaytimeunitsused; int saturdaytimeunitsused; int sundaytimeunitsused; try{ //sets variable values listname = household.get(householdList.getSelectedIndex()).getlistname(); electronic = electronicTextField.getText(); pluggedin = Double.parseDouble(timeTextField.getText()); pluggedtimeunits = timeComboBox.getSelectedIndex(); electricityused = Double.parseDouble(energyTextField.getText()); Quantity = Double.parseDouble(quantityTextField.getText()); mondaytimeused = Double.parseDouble(mondayTextField.getText()); tuesdaytimeused = Double.parseDouble(tuesdayTextField.getText()); wednesdaytimeused = Double.parseDouble(wednesdayTextField.getText()); thursdaytimeused = Double.parseDouble(thursdayTextField.getText()); fridaytimeused = Double.parseDouble(fridayTextField1.getText()); saturdaytimeused = Double.parseDouble(saturdayTextField.getText()); sundaytimeused = Double.parseDouble(sundayTextField.getText());

holidaytimeused = Double.parseDouble(holidayTextField.getText()); mondaytimeunitsused = mondayComboBox.getSelectedIndex(); tuesdaytimeunitsused = tuesdayComboBox.getSelectedIndex(); wednesdaytimeunitsused = wednesdayComboBox.getSelectedIndex(); thursdaytimeunitsused = thrusdayComboBox.getSelectedIndex(); fridaytimeunitsused = fridayComboBox1.getSelectedIndex(); saturdaytimeunitsused = saturdayComboBox.getSelectedIndex(); sundaytimeunitsused = sundayComboBox.getSelectedIndex(); holidaytimeunitsused = holidayComboBox.getSelectedIndex(); timeunitsused = timeComboBox.getSelectedIndex(); //sets Madebefore2007 true or false depending on the user selection if(Madebefore2007CheckBox.isSelected()) { Madebefore2007 = true; } else { Madebefore2007 = false; } Household e = new Household(); //sets all variables to a certain value e.setlistname(listname); e.setelectricity(electricityused); e.setelectronicname(electronic); e.settimein(pluggedin); e.settimeunitsin(pluggedtimeunits); e.setquantity(Quantity); e.setMadebefore2007(Madebefore2007); e.setmondaytimeused(mondaytimeused); e.settuesdaytimeused(tuesdaytimeused); e.setwednesdaytimeused(wednesdaytimeused); e.setthursdaytimeused(thursdaytimeused); e.setfridaytimeused(fridaytimeused); e.setsaturdaytimeused(saturdaytimeused); e.setsundaytimeused(sundaytimeused); e.setholidaytimeused(holidaytimeused); e.setmondaytimeunitsused(mondaytimeunitsused); e.settuesdaytimeunitsused(tuesdaytimeunitsused); e.setwednesdaytimeunitsused(wednesdaytimeunitsused); e.setthursdaytimeunitsused(thursdaytimeunitsused); e.setfridaytimeunitsused(fridaytimeunitsused); e.setsaturdaytimeunitsused(saturdaytimeunitsused); e.setsundaytimeunitsused(sundaytimeunitsused); e.setholidaytimeunitsused(holidaytimeunitsused); e.settimeunitsused(timeunitsused);

//adds all the data to the household Array household.add(e); //displays the electronic to the electronics list displayElectronicsToList(); //writes the new data into the houselist textfile electronicwriteFile(); //writes the new data into the houselist textfile WriteFile wf = new WriteFile("houselist_1.txt"); for(int i = 0; i < household.size(); i++) { //gets info on electronic Household a = household.get(i); wf.write(a.getlistname()); wf.write(""+a.getelectronicname()); wf.write(""+a.gettimein()); wf.write(""+a.gettimeunitsused()); wf.write(""+a.getelectricity()); wf.write(""+a.getpenergy()); wf.write(""+a.getquantity()); wf.write(""+a.getmondaytimeused()); wf.write(""+a.getmondaytimeunitsused()); wf.write(""+a.gettuesadytimeused()); wf.write(""+a.gettuesdaytimeunitsused()); wf.write(""+a.getwednesdaytimeuesed()); wf.write(""+a.getwednesdaytimeunitsused()); wf.write(""+a.getthursdaytimeused()); wf.write(""+a.getthursdaytimeunitsused()); wf.write(""+a.getfridaytimeused()); wf.write(""+a.getfridaytimeunitsused()); wf.write(""+a.getsaturdaytimeused()); wf.write(""+a.getsaturdaytimeunitsused()); wf.write(""+a.getsundaytimeused()); wf.write(""+a.getsundaytimeunitsused()); wf.write(""+a.getholidaytimeused()); wf.write(""+a.getholidaytimeunitsused()); int numTrans = a.getlistname().length(); for(int j = 0; j < numTrans; j++) { //writes data wf.write(a.getelectronicname()); } } //displays electronics to list displayElectronicsToList();

//closes the write file wf.close(); //catches the program is something goes wrong //informs the user that they have entered incorrect information into the program causing it to fail }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "The user have not entered the information needed correctly. Please go back and correct information.");} } //removes an electronic from the list private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try{ //removes the selected electronic household.remove(electronicsList.getSelectedIndex()); //displays the electronics to list displayElectronicsToList(); //writes out the remeoved electronic electronicwriteFile(); //catches the program and informs the user that before selecting the button they must first select an electronic to remove }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User has not selected an electronic to deleate");} } private void Madebefore2007CheckBoxActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void quantityTextFieldActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } //makes the day's panels visable to the user, corrisponding with the day selected from the list private void daysListMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: try{ //make the days visable if(daysList.getSelectedIndex() == 0){ Monday.setVisible(true); } else if(daysList.getSelectedIndex() == 1){ Tuesday.setVisible(true); } else if(daysList.getSelectedIndex() == 2){ Wednesday.setVisible(true);

} else if(daysList.getSelectedIndex() == 3){ Thursday.setVisible(true); } else if(daysList.getSelectedIndex() == 4){ Friday.setVisible(true); } else if(daysList.getSelectedIndex() == 5){ Saturday.setVisible(true); } else if(daysList.getSelectedIndex() == 6){ Sunday.setVisible(true); } else if(daysList.getSelectedIndex() == 7){ Holiday.setVisible(true); } //catches the program if the user somehow manages to select an empty space/value and tell the user so }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User has not selected a valid day");} } //sets the holiday panel not-visable private void addholidayButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try{ Holiday.setVisible(false); //tells the user that they have entered a non-numerical value into the textbox and catches the program }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User has entered a non-numerical symbol");} } //sets the saturday panel not-visable private void addsaturdayButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try{ //sets saturday panel to not-visable Saturday.setVisible(false); //informs the user that they have entered in an invalid number }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User has entered a non-numerical symbol");} } //sets the friday panel not visable private void addfridayButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try{ //sets the friday panel to not visable Friday.setVisible(false);

//catches program and informs the user that they have entered in an invalid number }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User has entered a non-numerical symbol");} } //sets the sunday panel not visable private void addsundayButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try{//sets the panel not visable Sunday.setVisible(false); //catches the program and tells user that they have entered in a unrecagnisable number }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User has entered a non-numerical symbol");} } //closes the main program and opens up a help page private void helpButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //sets the help page visable new Help().setVisible(true); //disposes of the main program this.dispose(); } //calculates the estimated amount of electricity used and the estimated amount it would cost the user private void calculateButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //variables used within the calculate button String electronic; Double pluggedin; int pluggedtimeunits; Double electricityused; Double Quantity; Boolean Madebefore2007; double mondaytimeused; double tuesdaytimeused; double wednesdaytimeused; double thursdaytimeused; double fridaytimeused; double saturdaytimeused; double sundaytimeused; double holidaytimeused; double timeunitsused; double holidaytimeunitsused; double mondaytimeunitsused;

double tuesdaytimeunitsused; double wednesdaytimeunitsused; double thursdaytimeunitsused; double fridaytimeunitsused; double saturdaytimeunitsused; double sundaytimeunitsused; double cost; int numberofholidays; int holidays = 0; int starts; int ends; double period = 1; double periodunits = 1/60; double totalcost; double totalelectricity; double days = 1; double time; double phantomenergyused = 0.5; //defines the value of the start and end of the time period starts = startsComboBox.getSelectedIndex(); ends = endsComboBox.getSelectedIndex(); try{ //gets the period calculated in period = periodTextField.getScrollOffset(); //ensures that the user enters only a whole numarical number }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User must only enter a whole numerical value in textfield.");} //gives the period units the correct value associated with their unit called //EX: periodComboBox.getSelectedIndex() == 0, is the unit minutes // and is thus given the value of 1/60; because a single minute is 1/60th of an hour. if(periodComboBox.getSelectedIndex() == 0) { periodunits = 1/60; //because the unit given is in minutes this ensures that user keeps the correct days he/she starts on if(periodunits*period < 1440) { starts = ends; } } else if(periodComboBox.getSelectedIndex() == 1) {

periodunits = 1; //ensures start = end if the time is less than the time period of a day. if(periodunits*period < 24) { starts = ends; } } //shows that there are 24 hours in a day and uses that to calculate total electricity used else if(periodComboBox.getSelectedIndex() == 2) { periodunits = 24; } //sets variable cost to be the selected value from the costComboBox cost = costComboBox.getSelectedIndex(); //sets the number of holidays from the textfield numberofholidays = numberofholidaysTextField.getSelectionStart(); //makes electronic = to the info in the corrisponding textfield electronic = electronicTextField.getText(); //makes the time plugged in = to the info in the corrisponding textfield pluggedin = Double.parseDouble(timeTextField.getText()); //makes the units plugged in = to the info in the corrisponding textfield pluggedtimeunits = timeComboBox.getSelectedIndex(); //sets the variables electricityused value from the energTextField electricityused = Double.parseDouble(energyTextField.getText()); //sets the number of the electronic in the household Quantity = Double.parseDouble(quantityTextField.getText()); //sets Madebefore2007 true or false based on user selection Madebefore2007 = Madebefore2007CheckBox.isSelected(); //sets the time used for the day mondaytimeused = Double.parseDouble(mondayTextField.getText()); //sets the time used for the day tuesdaytimeused = Double.parseDouble(tuesdayTextField.getText()); //sets the time used for the day wednesdaytimeused = Double.parseDouble(wednesdayTextField.getText()); //sets the time used for the day thursdaytimeused = Double.parseDouble(thursdayTextField.getText()); //sets the time used for the day fridaytimeused = Double.parseDouble(fridayTextField1.getText()); //sets the time used for the day saturdaytimeused = Double.parseDouble(saturdayTextField.getText()); //sets the time used for the day sundaytimeused = Double.parseDouble(sundayTextField.getText()); //sets the time used for the day holidaytimeused = Double.parseDouble(holidayTextField.getText());

//sets the time units used for the day mondaytimeunitsused = mondayComboBox.getSelectedIndex(); //sets the time units used for the day tuesdaytimeunitsused = tuesdayComboBox.getSelectedIndex(); //sets the time units used for the day wednesdaytimeunitsused = wednesdayComboBox.getSelectedIndex(); //sets the time units used for the day thursdaytimeunitsused = thrusdayComboBox.getSelectedIndex(); //sets the time units used for the day fridaytimeunitsused = fridayComboBox1.getSelectedIndex(); //sets the time units used for the day saturdaytimeunitsused = saturdayComboBox.getSelectedIndex(); //sets the time units used for the day sundaytimeunitsused = sundayComboBox.getSelectedIndex(); //sets the time units used for the day holidaytimeunitsused = holidayComboBox.getSelectedIndex(); //sets the time units used for the time in timeunitsused = timeComboBox.getSelectedIndex(); try{ //sets millisecond value if selected by the user if(mondaytimeunitsused == 0) { mondaytimeunitsused = 1/360000; } //sets the seconds value if selected by the user else if(mondaytimeunitsused == 1) { mondaytimeunitsused = 1/3600; } //sets the minute value if selected by the user else if(mondaytimeunitsused == 2) { mondaytimeunitsused = 1/60; } //sets the hour value if selected by the user else if(mondaytimeunitsused == 3) { mondaytimeunitsused = 1; } //sets the day value if selected by the user else if(mondaytimeunitsused == 4) { mondaytimeunitsused = 24; } //sets the units to milliseconds

if(tuesdaytimeunitsused == 0) { tuesdaytimeunitsused = 1/360000; } //sets the units to seconds else if(tuesdaytimeunitsused == 1) { tuesdaytimeunitsused = 1/3600; } //sets the units to minutes else if(tuesdaytimeunitsused == 2) { tuesdaytimeunitsused = 1/60; } //sets the units to an hours value else if(tuesdaytimeunitsused == 3) { tuesdaytimeunitsused = 1; } //sets the units = to a day else if(tuesdaytimeunitsused == 4) { tuesdaytimeunitsused = 24; } //sets the value to a millisecond if(wednesdaytimeunitsused == 0) { wednesdaytimeunitsused = 1/360000; } //sets value = to a second else if(wednesdaytimeunitsused == 1) { wednesdaytimeunitsused = 1/3600; } //sets value = to a minute else if(wednesdaytimeunitsused == 2) { wednesdaytimeunitsused = 1/60; } //sets value = to an hour else if(wednesdaytimeunitsused == 3) { wednesdaytimeunitsused = 1; } //sets value = to a full day

else if(wednesdaytimeunitsused == 4) { wednesdaytimeunitsused = 24; } //sets value = to a millisecond if(thursdaytimeunitsused == 0) { thursdaytimeunitsused = 1/360000; } //sets value = to a second else if(thursdaytimeunitsused == 1) { thursdaytimeunitsused = 1/3600; } //sets value = to a minute else if(thursdaytimeunitsused == 2) { thursdaytimeunitsused = 1/60; } //sets value = to an hour else if(thursdaytimeunitsused == 3) { thursdaytimeunitsused = 1; } //sets value = to a day else if(thursdaytimeunitsused == 4) { thursdaytimeunitsused = 24; } //sets value = to a millisecond if(fridaytimeunitsused == 0) { fridaytimeunitsused = 1/360000; } //sets value = to a second else if(fridaytimeunitsused == 1) { fridaytimeunitsused = 1/3600; } //sets value = to a minute else if(fridaytimeunitsused == 2) { fridaytimeunitsused = 1/60; }

//sets value = to an hour else if(fridaytimeunitsused == 3) { fridaytimeunitsused = 1; } //sets value = to a day else if(fridaytimeunitsused == 4) { fridaytimeunitsused = 24; } //sets value = to a milisecond if(saturdaytimeunitsused == 0) { saturdaytimeunitsused = 1/360000; } //sets value = to a second else if(saturdaytimeunitsused == 1) { saturdaytimeunitsused = 1/3600; } //sets value = to a minute else if(saturdaytimeunitsused == 2) { saturdaytimeunitsused = 1/60; } //sets value = to an hour else if(saturdaytimeunitsused == 3) { saturdaytimeunitsused = 1; } //sets value = to a day else if(saturdaytimeunitsused == 4) { saturdaytimeunitsused = 24; } //sets value = to a millisecond if(sundaytimeunitsused == 0) { sundaytimeunitsused = 1/360000; } //sets value to a second else if(sundaytimeunitsused == 1) { sundaytimeunitsused = 1/3600;

} //sets the value = to a minute else if(sundaytimeunitsused == 2) { sundaytimeunitsused = 1/60; } //sets value = to an hour else if(sundaytimeunitsused == 3) { sundaytimeunitsused = 1; } //sets value = to a day else if(sundaytimeunitsused == 4) { sundaytimeunitsused = 24; } //sets value = to a millisecond if(holidaytimeunitsused == 0) { holidaytimeunitsused = 1/360000; } //sets value = to a second else if(holidaytimeunitsused == 1) { holidaytimeunitsused = 1/3600; } //sets value = to a minute else if(holidaytimeunitsused == 2) { holidaytimeunitsused = 1/60; } //sets value = to an hour else if(holidaytimeunitsused == 3) { holidaytimeunitsused = 1; } //sets value = to a day else if(holidaytimeunitsused == 4) { holidaytimeunitsused = 24; } //catches statment if the user errs and accidently enters a non-numerical value into the textbox }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User must only enter a whole numerical value in textfield.");}

//adds value to the variable holidays for each checkbox selected if(mondayCheckBox.isSelected()) { holidays++; } else if(tuesdayCheckBox.isSelected()) { holidays++; } else if(wednesdayCheckBox.isSelected()) { holidays++; } else if(thursdayCheckBox.isSelected()) { holidays++; } else if(fridayCheckBox.isSelected()) { holidays++; } else if(saturdayCheckBox.isSelected()) { holidays++; } else if(sundayCheckBox.isSelected()) { holidays++; } //runs only while the # of holidays are greater than 0, and the # of holidays given by the user match the # of holidays selected while(numberofholidays > 0 && holidays == numberofholidays) { //allows units of differant days to = that of a holiday if the appropriate chechbox is selected try{ if(mondayCheckBox.isSelected()) { mondaytimeused = holidaytimeused; mondaytimeunitsused = holidaytimeunitsused; } else if(tuesdayCheckBox.isSelected()) {

tuesdaytimeused = holidaytimeused; tuesdaytimeunitsused = holidaytimeunitsused; } else if(wednesdayCheckBox.isSelected()) { wednesdaytimeused = holidaytimeused; wednesdaytimeunitsused = holidaytimeunitsused; } else if(thursdayCheckBox.isSelected()) { thursdaytimeused = holidaytimeused; thursdaytimeunitsused = holidaytimeunitsused; } else if(fridayCheckBox.isSelected()) { fridaytimeused = holidaytimeused; fridaytimeunitsused = holidaytimeunitsused; } else if(saturdayCheckBox.isSelected()) { saturdaytimeused = holidaytimeused; saturdaytimeunitsused = holidaytimeunitsused; } else if(sundayCheckBox.isSelected()) { sundaytimeused = holidaytimeused; sundaytimeunitsused = holidaytimeunitsused; } //sets the amount of phantom energy if(Madebefore2007 == true) { phantomenergyused = 0.5; } else { phantomenergyused = 0; } //catches program if user selects to many or to little holidays, than specified }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User has selected too many, or too little, holidays.");} } //makes it so that this only works for "days" if(periodunits == 2)

{ //takes the "days" and divides is by the 7 days of the week time = period/7; for(double index = 0; (index/7) == time; index++) { { //calculates the days the user wishes to calculate the electricity use and cost of days = ((mondaytimeused*mondaytimeunitsused) + (tuesdaytimeused*tuesdaytimeunitsused) + (wednesdaytimeused*wednesdaytimeunitsused) + (thursdaytimeused*thursdaytimeunitsused) + (fridaytimeused*fridaytimeunitsused) + (saturdaytimeused*saturdaytimeunitsused) + (sundaytimeused*sundaytimeunitsused))/index; } } }

//calculates the total electricity consumed in the time period specified totalelectricity = Quantity*(((period*periodunits)*(days))+ (phantomenergyused * pluggedin * pluggedtimeunits)) ; //calculates the cost of the electricity consumed totalcost = totalelectricity*cost; //displays the amount of electricity used and the cost to the user totalcostTextField.setText("" + totalcost); totalelectricityTextField.setText("" + totalelectricity); } //displays the household values to the list private void displayHouseholdToList() { try{ //sets householdNames = to the array household's size String[] householdNames = new String[household.size()]; //displays only when less than the length of the householdNames String/Array for(int i = 0; i < householdNames.length; i++) { //gets the list names from household within the value of i householdNames[i] = household.get(i).getlistname(); }

//sets the listData = to the householdnames householdList.setListData(householdNames); }catch(Exception e){} } //allows electronics in list to be displayed private void displayElectronicsToList() { try{ //sets electronicNames = tp the size of the array household String[] electronicNames = new String[household.size()]; for(int i = 0; i < electronicNames.length; i++) { //gets the electronicname from the array household electronicNames[i] = household.get(i).getelectronicname(); } //sets electronicList to the name of the selected electronic electronicsList.setListData(electronicNames); //catches statement if errors }catch(Exception e){} } //allows holiday info to be made visible private void holidayCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //allows holiday info to be made visable if the holidayCheckBox is selected if(holidayCheckBox.isSelected()) { holidayLabel1.setVisible(true); numberofholidaysTextField.setVisible(true); mondayCheckBox.setVisible(true); tuesdayCheckBox.setVisible(true); wednesdayCheckBox.setVisible(true); thursdayCheckBox.setVisible(true); fridayCheckBox.setVisible(true); saturdayCheckBox.setVisible(true); sundayCheckBox.setVisible(true); } //other-wise all the holiday info is made not-visable if checkbox is not selected else { holidayLabel1.setVisible(false); numberofholidaysTextField.setVisible(false);

mondayCheckBox.setVisible(false); tuesdayCheckBox.setVisible(false); wednesdayCheckBox.setVisible(false); thursdayCheckBox.setVisible(false); fridayCheckBox.setVisible(false); saturdayCheckBox.setVisible(false); sundayCheckBox.setVisible(false); } } //allows calculate info to be made visable private void CalculatesetvisableButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //sets selected button false while making the panel with all the calculate info visible CalculatesetvisableButton.setVisible(false); timePanel.setVisible(true); } //displays electronics associated with the list value private void householdListValueChanged(javax.swing.event.ListSelectionEvent evt) { // TODO add your handling code here: //sets the variable listindex as the selected value from the householdlist int listindex = householdList.getSelectedIndex(); //displays the electronics related to the selected value from the householdlist if(householdList.getSelectedIndex() != -1){ Household a = household.get(householdList.getSelectedIndex()); displayElectronicsToList(); } //gets info amd displays it to the text fields Household eTemp = household.get(listindex); listnameTextField.setText(eTemp.getlistname()); } //displays electronic data in the appropriate places when vlaue is selected. private void electronicsListValueChanged(javax.swing.event.ListSelectionEvent evt) { // TODO add your handling code here: int listindex = electronicsList.getSelectedIndex(); //gets info amd displays it to the text fields Household eTemp = household.get(listindex); electronicTextField.setText(eTemp.getelectronicname()); timeTextField.setText("" + eTemp.gettimein()); energyTextField.setText("" + eTemp.getelectricity());

penergyTextField.setText("" + eTemp.getpenergy()); quantityTextField.setText("" + eTemp.getquantity()); Madebefore2007CheckBox.setSelected(eTemp.getMadebefore2007()); mondayTextField.setText("" + eTemp.getmondaytimeused()); tuesdayTextField.setText("" + eTemp.gettuesadytimeused()); wednesdayTextField.setText("" + eTemp.getwednesdaytimeuesed()); thursdayTextField.setText("" + eTemp.getthursdaytimeused()); fridayTextField1.setText("" + eTemp.getfridaytimeused()); saturdayTextField.setText("" + eTemp.getsaturdaytimeused()); sundayTextField.setText("" + eTemp.getsundaytimeused()); holidayTextField.setText("" + eTemp.getholidaytimeused()); timeComboBox.setSelectedIndex(eTemp.gettimeunitsin()); mondayComboBox.setSelectedIndex(eTemp.getmondaytimeunitsused()); tuesdayComboBox.setSelectedIndex(eTemp.gettuesdaytimeunitsused()); wednesdayComboBox.setSelectedIndex(eTemp.getwednesdaytimeunitsused()); thrusdayComboBox.setSelectedIndex(eTemp.getthursdaytimeunitsused()); fridayComboBox1.setSelectedIndex(eTemp.getfridaytimeunitsused()); saturdayComboBox.setSelectedIndex(eTemp.getsaturdaytimeunitsused()); sundayComboBox.setSelectedIndex(eTemp.getsundaytimeunitsused()); holidayComboBox.setSelectedIndex(eTemp.getholidaytimeunitsused()); } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new NewBill().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton CalculatesetvisableButton; private javax.swing.JPanel Friday; private javax.swing.JPanel Holiday; private javax.swing.JCheckBox Madebefore2007CheckBox; private javax.swing.JPanel Monday; private javax.swing.JPanel Saturday; private javax.swing.JPanel Sunday; private javax.swing.JPanel Thursday; private javax.swing.JPanel Tuesday; private javax.swing.JPanel Wednesday; private javax.swing.JButton addButton;

private javax.swing.JButton addfridayButton1; private javax.swing.JButton addholidayButton; private javax.swing.JButton addmondayButton; private javax.swing.JButton addsaturdayButton; private javax.swing.JButton addsundayButton; private javax.swing.JButton addthrusdayButton; private javax.swing.JButton addtuesdayButton; private javax.swing.JButton addwednesdayButton; private javax.swing.JButton calculateButton; private javax.swing.JComboBox costComboBox; private javax.swing.JLabel costLabel; private javax.swing.JList daysList; private javax.swing.JLabel electricityusedLabel; private javax.swing.JTextField electronicTextField; private javax.swing.JLabel electronicsLabel; private javax.swing.JList electronicsList; private javax.swing.JComboBox endsComboBox; private javax.swing.JTextField energyTextField; private javax.swing.JButton exitButton; private javax.swing.JCheckBox fridayCheckBox; private javax.swing.JComboBox fridayComboBox1; private javax.swing.JLabel fridayLabel1; private javax.swing.JTextField fridayTextField1; private javax.swing.JLabel fridaytimeLabel1; private javax.swing.JButton helpButton; private javax.swing.JCheckBox holidayCheckBox; private javax.swing.JComboBox holidayComboBox; private javax.swing.JLabel holidayLabel; private javax.swing.JLabel holidayLabel1; private javax.swing.JTextField holidayTextField; private javax.swing.JLabel holidaytimeLabel; private javax.swing.JList householdList; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JLabel listnameLabel; private javax.swing.JTextField listnameTextField; private javax.swing.JCheckBox mondayCheckBox; private javax.swing.JComboBox mondayComboBox; private javax.swing.JLabel mondayLabel; private javax.swing.JTextField mondayTextField; private javax.swing.JLabel mondaytimeLabel; private javax.swing.JButton newlistButton;

private javax.swing.JLabel newlistLabel; private javax.swing.JPanel newlistPanel; private javax.swing.JButton newlistnameButton; private javax.swing.JTextField numberofholidaysTextField; private javax.swing.JLabel penergyLabel; private javax.swing.JTextField penergyTextField; private javax.swing.JComboBox periodComboBox; private javax.swing.JLabel periodLabel; private javax.swing.JTextField periodTextField; private javax.swing.JLabel quantityLabel; private javax.swing.JTextField quantityTextField; private javax.swing.JButton removeButton; private javax.swing.JButton removeButton1; private javax.swing.JCheckBox saturdayCheckBox; private javax.swing.JComboBox saturdayComboBox; private javax.swing.JLabel saturdayLabel; private javax.swing.JTextField saturdayTextField; private javax.swing.JLabel saturdaytimeLabel; private javax.swing.JComboBox startsComboBox; private javax.swing.JCheckBox sundayCheckBox; private javax.swing.JComboBox sundayComboBox; private javax.swing.JLabel sundayLabel; private javax.swing.JTextField sundayTextField; private javax.swing.JLabel sundaytimeLabel; private javax.swing.JComboBox thrusdayComboBox; private javax.swing.JCheckBox thursdayCheckBox; private javax.swing.JLabel thursdayLabel; private javax.swing.JTextField thursdayTextField; private javax.swing.JLabel thursdaytimeLabel; private javax.swing.JComboBox timeComboBox; private javax.swing.JLabel timeLabel; private javax.swing.JPanel timePanel; private javax.swing.JTextField timeTextField; private javax.swing.JLabel totalLabel; private javax.swing.JTextField totalcostTextField; private javax.swing.JTextField totalelectricityTextField; private javax.swing.JCheckBox tuesdayCheckBox; private javax.swing.JComboBox tuesdayComboBox; private javax.swing.JLabel tuesdayLabel; private javax.swing.JTextField tuesdayTextField; private javax.swing.JLabel tuesdaytimeLabel; private javax.swing.JCheckBox wednesdayCheckBox; private javax.swing.JComboBox wednesdayComboBox; private javax.swing.JLabel wednesdayLabel; private javax.swing.JTextField wednesdayTextField; private javax.swing.JLabel wednesdaytimeLabel;

// End of variables declaration }

Title Page:
package Electricbill; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * Title.java * * Created on Dec 13, 2010, 12:58:41 PM */ /** * * @author 1010217 */ public class Title extends javax.swing.JFrame { /** Creates new form Title */ public Title() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel1 = new javax.swing.JLabel(); enterButton = new javax.swing.JButton(); helpButton = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Welcome To Electronic Bill"); jLabel1.setFont(new java.awt.Font("Times New Roman", 3, 36)); // NOI18N jLabel1.setText("Welcome to Electronic Bill"); enterButton.setText("Enter"); enterButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { enterButtonActionPerformed(evt); } }); helpButton.setText("Help"); helpButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { helpButtonActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(28, Short.MAX_VALUE) .addComponent(jLabel1) .addGap(49, 49, 49)) .addGroup(layout.createSequentialGroup() .addGap(143, 143, 143) .addComponent(helpButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(enterButton) .addContainerGap(214, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(100, 100, 100) .addComponent(jLabel1)

.addGap(48, 48, 48) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS ELINE) .addComponent(enterButton) .addComponent(helpButton)) .addContainerGap(87, Short.MAX_VALUE)) ); pack(); }// </editor-fold> //makes program go on to the main part of the program private void enterButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //sets the main part of the program new NewBill().setVisible(true); //disposes of this page this.dispose(); } //makes the help page visable private void helpButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //sets the help page visable new Help().setVisible(true); //sets this to be disposed this.dispose(); } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Title().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton enterButton; private javax.swing.JButton helpButton; private javax.swing.JLabel jLabel1; // End of variables declaration }

Help Menu:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * Help.java * * Created on Mar 11, 2011, 1:01:10 PM */ package Electricbill; //Java import for the ArrayList, allows the program to use the ArrayList import java.util.ArrayList; /** * * @author 1010217 */ public class Help extends javax.swing.JFrame { //Help ArrayList for the help page (this page) ArrayList<Help> help = new ArrayList<Help>(); /** Creates new form Help */ public Help() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); helpList = new javax.swing.JList(); jLabel1 = new javax.swing.JLabel(); backButton = new javax.swing.JButton(); exitButton = new javax.swing.JButton();

jPanel1 = new javax.swing.JPanel(); helpTextField1 = new javax.swing.JTextField(); helpTextField2 = new javax.swing.JTextField(); helpTextField3 = new javax.swing.JTextField(); helpTextField4 = new javax.swing.JTextField(); helpTextField5 = new javax.swing.JTextField(); helpTextField6 = new javax.swing.JTextField(); helpTextField7 = new javax.swing.JTextField();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); helpList.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); helpList.setModel(new javax.swing.AbstractListModel() { String[] strings = { "Title Screen", "Add new List", "Add new Electronic", "Remove list or Electronic ", "Calculate Bill and Electricity Use" }; public int getSize() { return strings.length; } public Object getElementAt(int i) { return strings[i]; } }); helpList.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { helpListMouseClicked(evt); } }); jScrollPane1.setViewportView(helpList); jLabel1.setText("Help List:"); jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); backButton.setText("Back"); backButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { backButtonActionPerformed(evt); } }); exitButton.setText("Exit"); exitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exitButtonActionPerformed(evt); } });

helpTextField1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); helpTextField2.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); helpTextField3.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); helpTextField4.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); helpTextField5.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); helpTextField6.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(22, 22, 22) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING, false) .addComponent(helpTextField6, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE) .addComponent(helpTextField5, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE) .addComponent(helpTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE) .addComponent(helpTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE) .addComponent(helpTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE) .addComponent(helpTextField7) .addComponent(helpTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(27, Short.MAX_VALUE)) );

jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(24, 24, 24) .addComponent(helpTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(helpTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(helpTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(helpTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(helpTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(helpTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(helpTextField7, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA DING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addContainerGap(502, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA DING) .addGroup(layout.createSequentialGroup() .addGap(57, 57, 57) .addComponent(backButton) .addGap(29, 29, 29) .addComponent(exitButton)) .addGroup(layout.createSequentialGroup() .addGap(18, 18, 18) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(53, 53, 53)))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1)

.addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA DING, false) .addComponent(jScrollPane1) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS ELINE) .addComponent(exitButton) .addComponent(backButton)) .addGap(43, 43, 43)) ); pack(); }// </editor-fold> //disposes this form private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //dispose this form this.dispose(); } //goes back to the main part of the program private void backButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //sets the new bill to the users view new NewBill().setVisible(true); } //allows text to be displayed to certain text fields when certain indexes of the helpList is clicked private void helpListMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: //is the first houseList item is slected displays text if(helpList.getSelectedIndex() == 0){ helpTextField1.setText("Click the enter button "); helpTextField2.setText("to enter start the program."); helpTextField3.setText(""); helpTextField4.setText(""); helpTextField5.setText(""); helpTextField6.setText(""); helpTextField7.setText(""); }

//displays text if the second item is selected else if(helpList.getSelectedIndex() == 1){ helpTextField1.setText("Select the New List Button"); helpTextField2.setText(" to create a new list."); helpTextField3.setText(""); helpTextField4.setText(""); helpTextField5.setText(""); helpTextField6.setText(""); helpTextField7.setText(""); } //displays text if the third item is selected else if(helpList.getSelectedIndex() == 2){ helpTextField1.setText("Select the list you wish to add the electronic to "); helpTextField2.setText("and fill out the appropriate information. "); helpTextField3.setText("Be careful and make sure to fill out the week list data."); helpTextField4.setText("To access the data click on the day."); helpTextField5.setText("Then hit the add button. To edit the information "); helpTextField6.setText("simple select the electronic, change the information "); helpTextField7.setText("accordingly, select the edit button and deleate the old electronic."); } //displays text if the fourth item is selected else if(helpList.getSelectedIndex() == 3){ helpTextField1.setText("Select from the lists the information "); helpTextField2.setText("the user wishes to removed"); helpTextField3.setText("and then select the apropriate remove button."); helpTextField4.setText("Beware: deleated objects can not be recovered."); helpTextField5.setText(""); helpTextField6.setText(""); helpTextField7.setText(""); } //displays text if the 5th item is selected else if(helpList.getSelectedIndex() == 4){ helpTextField1.setText("Fill out the information, select the"); helpTextField2.setText("electronic from which you wish to "); helpTextField3.setText("calculate electricity usage and cost."); helpTextField4.setText("Next, select the calculate button."); helpTextField5.setText("If the user has not entered any data"); helpTextField6.setText("into the electronic list though this will not work"); helpTextField7.setText("as the program will have nothing to calculate from."); }

//sets all the textfields to be blank if no item from the helpList is selected else { helpTextField1.setText(""); helpTextField2.setText(""); helpTextField3.setText(""); helpTextField4.setText(""); helpTextField5.setText(""); helpTextField6.setText(""); helpTextField7.setText(""); } } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Help().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton backButton; private javax.swing.JButton exitButton; private javax.swing.JList helpList; private javax.swing.JTextField helpTextField1; private javax.swing.JTextField helpTextField2; private javax.swing.JTextField helpTextField3; private javax.swing.JTextField helpTextField4; private javax.swing.JTextField helpTextField5; private javax.swing.JTextField helpTextField6; private javax.swing.JTextField helpTextField7; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; // End of variables declaration }

Criteria C2: Handling errors


Error Handling

When an error is made the program is not nessasarily to blame, the user can make mistakes too. Because of this, while programming, the programmer should be aware of this and help the user not make errors as well as to fix them. Without there kinds of safeguards the program will likely crash and burn each and everytime the user tries to imput information into the program.

For my program I have implemented various try-catch statements throught the entire program to catch errors made by the user. Additionally, JOptionPanes were also used to show/suggest to the user what caused the error so that they can go back and correct it.

Example1 (from page 57): //removes a list from the houselist private void removeButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //removes a list from data try{ //removes the list household.remove(householdList.getSelectedIndex()); //displays the lists minus the now removed list displayHouseholdToList(); //writes the current list to file householdwriteFile(); //catches the program and informs the user that they must first select a list to remove }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User needs to select an item from list to remove.");}

In this example if the user doesnt select an item from the householdList, then the remove button does not remove any item from the list. Because nothing was selected the JOptionPane shows the user the message "User needs to select an item from list to remove." Thus showing the user what he/she did incorrectly.

Example 2 (pages 75-76):

Fig.1: Not selected

Fig.2: Selected

//allows holiday info to be made visible private void holidayCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //allows holiday info to be made visable if the holidayCheckBox is selected if(holidayCheckBox.isSelected()) { holidayLabel1.setVisible(true); numberofholidaysTextField.setVisible(true); mondayCheckBox.setVisible(true); tuesdayCheckBox.setVisible(true); wednesdayCheckBox.setVisible(true); thursdayCheckBox.setVisible(true); fridayCheckBox.setVisible(true); saturdayCheckBox.setVisible(true); sundayCheckBox.setVisible(true); } //other-wise all the holiday info is made not-visable if checkbox is not selected else { holidayLabel1.setVisible(false); numberofholidaysTextField.setVisible(false); mondayCheckBox.setVisible(false); tuesdayCheckBox.setVisible(false); wednesdayCheckBox.setVisible(false);

thursdayCheckBox.setVisible(false); fridayCheckBox.setVisible(false); saturdayCheckBox.setVisible(false); sundayCheckBox.setVisible(false); } }

In this example the program checks to see if the user selected the holidayCheckBox or not. If the CheckBox is selected then the program sets a variety of items visable to the user. If the user did not check the box then the program does not display he items to the user.

Example 3 (Page 71): //sets value = to a millisecond if(holidaytimeunitsused == 0) { holidaytimeunitsused = 1/360000; } //sets value = to a second else if(holidaytimeunitsused == 1) { holidaytimeunitsused = 1/3600; } //sets value = to a minute else if(holidaytimeunitsused == 2) { holidaytimeunitsused = 1/60; } //sets value = to an hour else if(holidaytimeunitsused == 3) { holidaytimeunitsused = 1; } //sets value = to a day else if(holidaytimeunitsused == 4) { holidaytimeunitsused = 24; }

//catches statment if the user errs and accidently enters a non-numerical value into the textbox }catch(Exception ex) {JOptionPane.showMessageDialog(rootPane, "User must only enter a whole numerical value in textfield.");}

In this example the program checks to see if the holidaytimeunitsused == a certain number. If it equals that number then the program sets the holidaytimeunitsused to a certain value. If the value does not = that certain number then the program goes down the line to see what number it does equal. Additionally, this example also uses one of the programs many try{ }catch methods. In this example the program can only receive an integer value (a whole number). Without the try{ }catch statement if the user input a non-integer value the program would simply crash. With the try{ }catch statement the program catches its-self and informs the user via JOptionPane that the "User must only enter a whole numerical value in textfield."

Criteria C3: Success of the program


Evidence that the program met all the objectives from A2

Objectives: The system will store: The current cost of electricity The appliances that are used in his/her house -name -number of that appliance in the household -electricity use -time used daily -time plugged in -phantom electricity use The time he/she wishes to calculate the bill from The number of appliances he/she wishes to calculate The appliances the user wishes to calculate The system will calculate: The amount of electricity used by the specified appliances in Watts The amount of money the electricity will cost him/her Evidence:

The first screenshot is taken of the program after filling out all the information for Toaster and then clicking the add button. The second is a screenshot of the resulting data; placed in a textfile, a direct result of adding Toaster to the program. Obviously the program does indeed store the data listed above.

In the third screenshot above you can see the that the electronic Toaster has been selected and the Estimated Total Cost and Electricity Used have been calculated. As stated in the above objectives.

Stage D Documentation

Criteria D1: Including an annotated hard copy of the test output


Annotated sample of all tests for the criteria in A2

1. Hard Copy New List


Test For List Name Input Michael Chun Expected Output Michael Chun Output Michael Chun

2. Hard Copy New Electronic (valid data)


Test For Electronic Name Time Plugged in Time Plugged in (Units) Electricity Used Phantom Energy Input Toaster 23 Minutes Expected Output Toaster 23 Minutes Output Toaster 23 Minutes

234 23

234 0

234 0 (because the Made before 2007 was selected) 2 Selected

Quantity Made before 2007

2 Selected

2 Selected

Monday (time and units)

123, Minutes

123, Minutes

123, Minutes

Tuesday (time and 3, Milliseconds units) Wednesday (time and units) Thrusday (time and units) Friday (time and units) Saturday (time and units) Sunday (time and units) Holiday (time and units) Displayed to List 3, Minutes

3, Milliseconds

3, Milliseconds

3, Minutes

3, Minutes

34, Minutes

34, Minutes

34, Minutes

34, Minutes

34, Minutes

34, Minutes

4, Minutes

4, Minutes

4, Minutes

43, Seconds

43, Seconds

43, Seconds

12, Minutes

12, Minutes

12, Minutes

Toaster

Toaster (displayed to list)

Toaster (displayed to list)

3. Hard Copy New Electronic (Invalid data)


Test For Electronic Name Time Plugged in Time Plugged in (Units) Electricity Used Phantom Energy Quantity Made before 2007 Monday (time and units) Input Computer sad Milliseconds Expected Output Error Error Error Output Error Error Error

g g f (Selected) (Left Blank)

Error Error Error Error Error

Error Error Error Error Error

Tuesday (time and (Left Blank) units) Wednesday (time and units) Thrusday (time and units) Friday (time and units) Saturday (time and units) Sunday (time and units) Holiday (time and units) Displayed to List (Left Blank)

Error

Error

Error

Error

(Left Blank)

Error

Error

(Left Blank)

Error

Error

(Left Blank)

Error

Error

(Left Blank)

Error

Error

(Left Blank)

Error

Error

Computer

Error

Error

In this screenshot the information entered into the program was almost all incorrect; inputing letters where there are supposed to be numbers and leaving some info unfilled. The program caught this in a try{}catch statement and displayed an error message.

4. Hard Copy Remove Button (working)


Test For Remove Button Action Selected item from list and clicked removed Expected Outcome Item is removed from list Outcome Item is removed from list

Before Remove button clicked.

After Remove button clicked.

5. Hard Copy Remove Button (not working)


Test For Action Expected Outcome Error Message; Item not removed from list Outcome

Remove Button

Selected item from list and clicked removed

Error Message; Item not removed from list

Before Remove button clicked.

After Remove button clicked.

6. Hard Copy Days List Selected


Test For Action Days List Selected Monday Clicked Expected Outcome Monday Panel made Visable Outcome Monday Panel Visable

Before Monday Selected.

After Monday Selected.

7. Hard Copy Electronics List Selected


Test For Electronics List Selected Action Electronic Clicked Expected Outcome Data appears Outcome Data Appears

Toaster Selected.

Computer Selected.

8. Hard Copy Calculate Button (working)


Tested For Cost of Electricity Day Starts on Day Ends on Time period Time units Holiday Checkbox Estimated Total Cost Estimated Total Electricity Input/Action 0.75 Monday Tuesday 1 Day Not Selected Calculate Button Calculate Button Expected Output 0.75 Monday Tuesday 1 Day Not Selected Estimated Total Cost Estimated Total Electricity Output 0.75 Monday Tuesday 1 Day Not Selected 9225.0 123.0

Before Calculate Button is clicked.

After Calculate Button is clicked.

9. Hard Copy Calculate Button (not working)


Tested For Cost of Electricity Day Starts on Day Ends on Time period Time units Holiday Checkbox Estimated Total Cost Estimated Total Electricity Input/Action 0.75 Monday Tuesday Sa Day Selected Calculate Button Calculate Button Expected Output 0.75 Monday Tuesday Error Day Holiday info made visable Error Error Output 0.75 Monday Tuesday Error Day Holiday info made visable Error; 187650.0 Error; 2502.0

Before Calculate Button is clicked.

After Calculate Button is clicked.

10. Hard Copy Help Page


Tested For Text displays when list item selected Back Button Exit Button Action/Input List selected Expected Outcome Text displays to textfields Program returns to the Main form Program Closes Outcome Text displays to textfields Program returns to the Main form Program Closes

Back Button Selected Exit Button Selected

Before List item Selected

After List item Title Screen: has been selected

Criteria D2: Evaluating solutions


Outline
For the most part the program answers the problem set. The program allows the user to create a list that can store electronics and their data. All of which can be deleted and added within the program or in Notepad, since I decided to have the program store its information in a textfile. The data can then be taken by the user to calculate a rough estimate of how much electricity the electronic will use and how much it the electricity will cost. From a test takers point of view the program is rather difficult to use and seems to be confusing. The programming is rather compact in that the main form has all the data and takes advantage of that to call data from one variable to another. It uses variables to set the major parameters of the application. The code is long in length but most of it is simple and basic code stretched out to encompass large parts of the program. Searching and sorting were not implemented in this program; the user simple selects what he/she wishes from the lists.

Effectiveness
The program fulfills almost all of the requirements initially set out with the small exceptions of not being able to calculate whole lists of data at once. However, this is not a serious limitation as the user can simply find the amount of electricity used and its cost one electronic at a time. The program could handle the calculating in other ways (eg via something akin to a simple calculator).

Efficiency
There are a few issues with the efficiency of the program but these do not impact the running time of the program significantly, other than for a few slight pauses/delays. This could probably be improved by cutting down on the code; making it shorter and more concise, and there for easier to go through. It was possible to have the data loaded from, and stored, in multiple textfiles specific to each account; but that would have been much more complicated, creating numerous delays and bugs in the program. The program used lots of variables, ranging from Booleans to Strings to doubles, some of which were probably not necessary. This is not a real problem to run the program though as there are not that many variables. The presence of all the variables though makes the program seem more cluttered and makes it harder for the programmer, or anyone trying to look at the code, to fully grasp the program. The program overall is not that big. Taking up very little computer memory.

Possible improvements
When first attempted the program was split into several forms all leading back to a main for, the main menu. Now the program is all lumped together and all in one form. This makes it slightly easier to access, but makes it a little more confusing for the user. An alternative approach would be to separate all the main forms again based on what their function is. This would allow the user to simply select the form they wished to work with and be able to have only information they wish to deal with present. However, as stated previously, the program would be a bit harder to access as it would be split into several main forms. Therefore this separation of the form is not really needed. The overall program could also be made to have more flexibility, allowing the program to be more versatile. Currently the program can calculate the estimated electricity used and the estimated cost of a single electronic in a time period, yet with a little more work the program could be made to calculate multiple electronics or even whole lists at once. In storing information the program currently stores data in a single textfile. The program could also be made to hold the data in multiple textfiles sorted by listname/user. This would allow for easier displaying o f the electronics for each user and would keep the program more organized. This would of course take more time and effort as it would complicate and change the program considerably. There are also a number of various usability issues that could be improved upon. Such as simple textbox placement, to how the program runs/works. It would have been very helpful to have more people look the program over and make suggestions. The programmer also could have tried to explain the program to various people and see if they could make sense of it.

Alternate approaches
The initial design of the program was to separate the program into parts corresponding to the different actions the user could initiate in the program. This design did not survive, as all the parts of the program were eventually merged to created a single MainUI. Of course the program could always be separated again. This would make testing and debugging much easier as the parts of the program being de-bugged would be smaller and hopefully simpler. The development of the program could have been better though, as stated in the above possible improvements. More user feedback would have been very helpful in allowing the program to be created in a more user friendly way. The programming code could also vary greatly. Different variables could have been used to find the estimated electricity used as well as the estimated cost.

The program could have been made shorter and simpler with more global variables and less user flexibility with the time units, as the program can only estimate the possible bill anyways. The program could also be focused in more than one textfile as stated earlier. This would make the program neater and hopefully easier to de-bug. Sadly this would all require considerably more work, time, and programming skill than the programmer currently has and is thus beyond his current reach.

Documentation of Mastery items


Mastery Item 1: Arrays Page 24 ArrayList for the entire program Mastery Item 2: User-defined Objects Pages 59-60 the user defines the values of various variables Mastery Item 4 Simple Selection (IfElse Statements): Pages 67-73 here the program uses If/Else Statements to determine the values of certain variabales if the selected index == a certain number. Mastery Item 5 Complex Selection: Page 73-74 here the program runs the code if the periodunits == 2 while the index/7 == the time. Mastery Item 6 Loops: Page 75 here the program loops until the index value is equal to the number of electronics in the selected list. Mastery Item 8 User Defined Methods: Page 59-61 here the user defines variables for the program. Mastery Item 9 User Defined Methods with Parameters Page 65-66 here the user selects a combobox that creates the value for the variable periodunits, all within the set parameters of the combobox. Mastery Item 10 User Defined Methods with appropriate return values: Page 65 here the program catches the code if the user has inputed an inappropriate value. Thus, ensuring that the user defines a method with the appropriate return value. Mastery Item 13 File I/O: Page 59-61 here the program stores the variable data into a textfile when the user selects the add button. Mastery Item 14 Use of additional libraries: Page 24 here the program has the imports for the JOptionPane and the ArrayList

Das könnte Ihnen auch gefallen