CSC 120 Programming Assignment 4

Note: You should not work on this assignment during lecture or lab class-time unless:
  1. You have completed all of the in-class assigned work for the day, and
  2. You have permission from the instructor.

This assignment must be handed in to the PA4 dropbox in D2L before the due date/time.

Overview:

Using the class definition you developed for Programming Assignment # 2, create a Java application that provides a Graphical User Interface that allows the user to enter data values in TextFields for each property of the class, and displays output as described in these instructions in a scrollable TextArea.

Instructions:

  1. Initial Set-up.

    1. Create a NetBeans Java Application named PA4 in your network space.  It should contain the class named MUFrame from the starter template we've used previously.  Start with the files named MUFrame.form and MUFrame.java stored in the MUFrameWithGUIDesigner.zip file that is available in the "Starter Templates" section of the CSC 120 Student Resources page of the course web site.  You won't need to use the MUPanel.java file for this assignment.

    2. Copy the .java file for the class you wrote for PA # 2 into the src folder of the PA4 project.

    3. Open the MUFrame.java file in the NetBeans editor, switch to "Source" view, and delete the three lines that refer to an object named muPanel.  After doing this, you should be able to run the MUFrame.java without errors an obtain a blank output screen.

  2. Ensure that your class from PA2 has all required parts.

    1. Your class must have at least 4 properties, at least 2 of which are a numeric type (either Integer or Double).  The class must have a constructor method that stores initial values in the properties of the object.  The class must have a "getter" method for each property, and the class must have a toString method that returns a String that shows all the property values.

    2. If your class doesn't satisfy all these requirements, fix it so that it does satisfy the requirements.  Failing to do this will result in point deductions for PA4.

  3. Create your User Interface.

    1. Switch to "Design" view for the MUFrame.java file in NetBeans, and create a User Interface for your program that has a TextField for each of the properties in the class you wrote for PA # 2.  Each of the fields should be preceded by a Label that describes what the user should enter into each field.

    2. Add two Buttons to the interface that will allow the user to click and display results as described later in these instructions.

    3. Add a TextArea to the interface.  This will be used for program output display.

    4. Be sure to "Edit Text" for each of the TextFields so that they are blank to start with, and "Edit Text" for each of the Labels so that they display appropriate messages to the user indicating what should be entered into each of the TextFields.  Also, "Edit Text" on the Buttons so that one of them displays a message saying "Process Form Data" or something like that, and the other Button's message should be something like "Display Numeric Statistics".

    5. Also be sure to "Change Variable Name" for all of the TextFields, the Buttons and the TextArea so that they use names that are meaningful to your program topic.  As an example, if your class has properties named albumName and tracksOnCD, then your should name your TextFields albumNameField and tracksOnCDField.

  4. Code the actionPerformed method for the "Process Form Data" Button.

    1. Double-click on the Button that will process the form data in your User Interface to make NetBeans insert an actionPerformed method into the MUFrame class.

    2. When the user clicks on this Button, your application should do the following in this order:
       
      1. retrieve all data from the TextFields into String objects
      2. instantiate a new object from your class (you will need to convert some input data into Integer and/or Double data types)
      3. display the results of the toString method called for the new object in the TextArea of the User Interface
      4. call the "getter" method of the new object for one of the numeric properties in your class, and add the value retrieved to a "total" variable of the proper data type.
      5. compare the value retrieved in the previous step with a maximum and a minimum variable of the proper type.  If the value retrieved from the "getter" method is larger than the maximum variable, it should be stored as the new value of the maximum variable.  If the value retrieved from the "getter" is smaller than the minimum variable, it should be stored as the new minimum.
      6. add one to a "count" variable that will keep track of how many times the "Process Form Data" button has been clicked.  This will be needed to calculate the average value described below.

    3. The messages appended to the TextArea should be displayed on separate lines, with a blank line between the output generated by successive button clicks.

    4. Of course your program will have to use Integer.parseInt and/or Double.parseDouble to convert the String data from the TextFields for the numeric properties of your object into the proper numeric type before instantiating your object.

  5. Code the actionPerformed method for the "Display Numeric Statistics" Button.

    1. Double-click on the other Button in your Interface to make NetBeans insert another actionPerformed method into the MUFrame class.

    2. When the user clicks on this Button, your application should calculate the average value of the numeric field you've chosen to use, and then display the total, average, minimum and maximum values that the user has entered for the numeric field.

    3. The average must be displayed with decimal places, even if the field you are averaging is an Integer field.  The average must be computed as a Double value, and show the exact average, not truncated to an Integer value.

    4. Display a blank line between the output generated by successive button clicks.

  6. Keep track of statistics for two or more properties of your class, if you would like.

    1. If it makes sense for your topic, you can separately keep track of the "total", "minimum" and "maximum" for each of your class' numeric properties.  Just be sure not to mix them up.

    2. When the user clicks on the Button that displays the statistics, be sure to clearly indicate in the output which property's statistics are being displayed on each line.

Example of Program Behavior:

Turning in your Program for Grading:

Convert your H:\CSC120\Java\PA4 folder into a .zip file named PA4.zip and submit it to the PA4 dropbox in D2L.

Note:  It is expected that each student will complete this assignment INDIVIDUALLY.

Grading Rubric:

PA4 Grading Rubric