CSC 120 Programming Assignment 3

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 submitted to the PA3 D2L dropbox before the beginning of class on the due date.

Overview:

Develop a Java Application program that displays at least three visual objects in the MUPanel that are changable when a button is clicked.  The objects must be displayed on a background that can be changed somehow when another button is clicked.  There must be at least two different effects that are caused when specific buttons are clicked, meaning that there must be at least two buttons in the user interface of the program. Other buttons may be used to control various properties of the objects' movements or changes, such as distance to move, etc.

Instructions:

  1. Create an application called PA3. It should contain two classes named MUFrame and MUPanel.  Start with the three files located 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.

  2. Create two more classes for objects that can be drawn in the MUPanel. One class will be a Background class, and draw a background for the scene. The other class is for objects that will be drawn on top of the background object. Both classes will have methods for changing the objects in some way. The background might change back and forth from day to night with clouds and sun or stars and moon, or rain & snow or whatever. The other objects might change colors, change shapes, move up and down, move sideways, grow, shrink, etc. You may not use the RoundHead class or any other class that has already been used in a lab or a class that already exists. However, you may use one or more of the objects that you created for PA1. Also, your objects must be more detailed than a simple circle or oval or square that can be drawn with only one or two method calls from the Graphics class.

  3. The MUPanel class must declare and instantiate one Background object, and at least 3 objects from your other class, and the paintComponent method of the MUPanel must call the draw methods of the background object and the other objects.  In addition, the MUPanel class needs to have methods that can change the background and other objects in some way (these "change" methods will be called from MUFrame when the buttons in the application are clicked by the user).

  4. Using the GUI Designer, add at least two Buttons to the MUFrame. At least one button must call a method in MUPanel that changes the appearance of the Background object. At least one button must call a method in MUPanel that changes all of the objects from the other class to move them or change their appearance. Of course these Buttons will need to have the proper code in their "actionPerformed" methods, and call muPanel.repaint(); at the end of the method as in Lab 6 and class demos.

  5. Enhancements are optional, but make your classes interesting and different from ones used by other people. Perhaps the Background could draw a room with stuff on the floor and walls, and maybe a light on the ceiling, and the other class could be a Furniture class. Or the background could be a city with streets, and the other class could be people or cars. Or a house & yard with Flowers (oh, wait we've done that already). Hmmmm, the jungle and animals, or ... Be creative!

    Something interesting you might want to explore would be displaying a JPG, GIF or PNG image as part of the objects in your scene, either as the background for your application or for the objects to be drawn on the background.  Consult the ImageWithFrame Demo for an example of how to do this in Java.

  6. Don't forget your comment header for MUPanel, and put a comment header in each of the other class files.

  7. As usual, when you have completed your NetBeans project for PA3 (including the comment header at the top of the four files with your name, etc.), use File Explorer to make a .zip file of the PA3 folder in your H:\CSC120\Java folder so that the file is named PA3.zip.  Then upload that file to the PA3 dropbox in D2L.

Examples of Program Behavior:

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

Grading Rubric:

CSC 120, PA3, your name, date & Description comments in MUPanel.java 4
Background class and one background object that draws a background for the "other" objects." The Backgound class has at least one method that can change the appearance of the background. 6
"Other" class is not like RoundHead, Flag, Boat, or any other class previously used in a lab or project and is not like some existing class in the handout space or a lab or project. It has at least one method that can move it and/or change its appearance. The program declares, instantiates, and displays at least 3 of these objects. 8
Both the Background class and the other class have comment headers at the top with your name, date, and description. 3
At least one working button, that can change the appearance of the background. Either one button changes it back and forth between two or more appearances (light & dark, rain & shine, etc), or two buttons, so that we can change it, then change it back again. 8
At least one working button, that changes the appearance of all of the other objects, or moves them, or changes and moves them. 8
Organization and readability of the Java code, including appropriate indenting. 3
Total Points ====> 40