HW03: Arrays of Objects due Mon 05 Feb 10:00

This assignment provides an opportunity to make use of classes ...
...ng existing code to utilize a new
data structure

Allowed and Disallowed Resources

In completing this assignment you MAY use/access the following resources:

You may NOT use/access:

Failure to abide by these guidelines will result in a zero for the assignment and the incident will be reported to the university provost as a violation of the university academic integrity policy. A second incident of academic dishonesty (whether from this course or another computer science course) will result in an F in the course.


Make sure that you have finished all of the lab day instructions and that your working space and bitbucket repository are appropriately in sync.

For this assignment you will modify the movies program we have been working on so that instead of having three parallel arrays you will have a single array of Movie objects. In this assignment you will make this change and get all parts of the program to work with the new arrangement.

You have already created a functional Movie class and have written a useful constructor and toString() method and so are well on your way.

Steps to Work on Before Friday

Here are some suggested steps to take prior to our class time on Friday:
  1. Take a moment to read the sample code and commentary in the section called “Arrays of Objects (non-OOP)” found in the CSCI 2320 Command Sheet (with commentary) document. Keep this code handy for the following steps.

  2. Copy your working movies program from hw02 into hw03. You should rename it to something like ArrayOfObjectsMovies.java to indicate how it will be different from the original. All of the remaining steps are to be taken in the new program.

  3. In main() delete the three parallel arrays and replace them with one array of Movie objects. Doing so will cause large portions of your program to stop working. Be sure to reserve 10,000 slots for the new array.

  4. In main() comment out all the method calls that pass the (original) three parallel arrays as parameters. Get the program to compile with those method calls commented out.

  5. Turn your attention to the loadMovies(). Modify the parameter list so it takes only one parameter: an array of Movie objects. Temporarily comment out the body of the method so your method looks something like this:
    public static int loadMovies(Movie [] movies) {
    	// new (temporary) code goes here
    all the original code is commented out here
    and pushed to the bottom. We'll deal with it

  6. Add new (temporary) code to loadMovies() that will (manually) create five new movie objects and make the array refer to them. The method should return the value 5 since there will be 5 entries in it. Something like this:
    movies[0]= new Movie("Up", "Animation", 2005);
    // four more movies go here
    return 5;

  7. Modify the displayAll() method so it takes two parameters (an array of Movie objects and the number of elements in the array). Then modify the body of the method to display the elements of the array. Remember, since you have written a toString() method you can print the first movie simply by do this:

  8. Once the program is putting 5 elements in the array and then displaying the array take a moment to update your documentation for loadMovies() and displayAll().

  9. Commit and push your work.

Steps for Friday and Following

Using what you learned in class you will complete the program so it is fully functional. Start by modifying loadMovies() to read from the file. Then you can systematically work through the other methods and convert them to make use of the new data structure. Some things to consider:


The assignment will be graded according to the following criteria:
Correctness 16 pts
Documentation 2 pts
Conventions 2 pts
Version Control 2 pts
Total 22 pts

Your program should be completely working and should follow all of the programming conventions named in class and explained in http://josephus.hsutx.edu/classes/all/javaconventions/ (including the use of comments that conform to the JavaDoc guidelines).

The instructor will grade your work based on what you have pushed to the hosted homework repository you have shared. For all assignments the program is due before the beginning of class on the due date. Repositories that show a commit time after that time will be graded as late.