CSC 120 Programming Assignment 7

Note: You should not work on this assignment during 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 submitted to the PA7 D2L dropbox before the beginning of class on the due date.

Overview:

Write a Java application that uses an array to represent a collection of at least 10 objects, and provides a user interface that gives a way to display information and/or statistics about the objects.  The program should declare and instantiate an array of objects that keep information about something in the real world (such as Countries, Books, Students, etc.), and then implement JButtons that will display information from the array or statistics about the items in the array in a JTextArea.

Instructions:

  1. Create an application called PA7. At the start, it should contain one class named MUFrame.  Start with the two files MUFrame.form and MUFrame.java in the MUFrameWithGUIDesigner.zip file available on the Student Resources page of the course web site.  Do NOT use an MUPanel class for this assignment -- you should only have an MUFrame class, since you are not doing any drawing.

  2. Think of some objects in the real world that have at least five properties that can be represented as private data members in a class definition. Examples would be the Book class and the Student class from Lab9, the Car class from Lab10, and the Country class used in the sample programs below. You may not use Books, Students, Cars or Countries for your PA7; you must think up some other class of objects to use for this assignment.

  3. Write a Java class definition for the class you will use for this assignment. This class must have at least five private data members, a constructor method, getter methods for each of the private data items, and a toString() method. You may also want to implement setter methods for each of the private data items, but setters are not required for this assignment.

  4. The user interface for this program that you build in MUFrame.java using the GUI Designer should have a TextArea for displaying the output of the program, and multiple Buttons that the user will click to obtain different results.  See the demo videos below for an example of how the user interface for this program might look.

  5. In the MUFrame class, declare an array of your objects, and then in the constructor method of the MUFrame class, instantiate the array so that it contains at least 10 elements.

  6. When you instantiate the objects in the array, you'll need to do them one at a time not in a loop.
    For example,
        nation[0] = new Country(some parameter values go here);
        nation[1] = new Country(some parameter values go here);
        nation[2] = new Country(some parameter values go here);
        ...
  7. The program must have a JButton that when clicked will display every element in the array on a separate line in a JTextArea that is visible in the output window. Of course you must use a loop to do this.

  8. The program must have at least two JButtons that when clicked will use a loop to calculate either the sum, average, minimum or maximum of a numeric data member of each element of the array. For example, you might have a button that would find the average population of all Country objects in the array, and another that would find the minimum area of any Country. The information must be displayed in the JTextArea that is visible in the output window.

  9. The program must have at least two JButtons that when clicked will use a loop to test each element of the array for some property of a String data member, using the .equals method. Either count the number of array elements that have the property being tested, or display them in the JTextArea. In the examples below, a button can be used to display only those countries that are located in Africa (continent.equals("Africa")).

  10. Look over your comment documentation, and especially make sure the MUFrame.java header comment describes the project well.

  11. Don't forget to document acknowledgements for any code you used from labs, book, instructors, etc., and help you received.

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

Samples:

Grading Rubric:

CSC 120, PA7, your name, date & Description comments in MUFrame.java 3
Class definition with at least five private data members, a constructor, and getter methods for each data member. 7
Array declared and instantiated, and at least 10 elements in the array. 3
JButton that displays every element in the array in a JTextArea, using a loop. 5
At least two Buttons that display sum, average, min and/or max of a numeric data member for the entire array in a JTextArea, using a loop. 12
At least two JButtons that test each element of the array for some property of a String data member using the .equals method in a JTextArea, using a loop. 12
Your code is easy to read, and indented consistently. 3
Total 45