On This Page
Overview
The main points of this assignment are to:
- Write recursive methods
- Create a graphical application by using a
JFrame class
- Use inheritance by extending a
JPanel class
- Use some of Java's graphics capabilities to draw shapes
- Make use of colors in Java
Recall that we covered graphics in lesson 8.2.
^ top
Lab Exercises
In these exercises you explore recursion.
Specifications
- Prepare a single text file named:
exercises.txt. Record answers to all the exercises in this file, labeling each answer with the exercise number.
- Complete self-test exercises 1, 2, 3 4 and 5 on page 650 of chapter 11 in your textbook.
- When finished, do not forget to upload your file to Blackboard as part of this assignment
^ top
Project Specifications
Write a Java application that displays a drawing on a JPanel added to a JFrame. The specifications include:
- The drawing must be done on a subclass of
JPanel named MyDrawing.
- The application must display a drawing between 400 to 1200 pixels wide by 300 to 800 pixels high.
- Your drawing must use at least two types of shapes drawn repeatedly (lines, rectangles, ovals, etc).
- Your drawing must use at least two colors.
- Draw at least one of your shapes using a loop statement.
- Draw at least one of your shapes using a recursive method and identify the method by name in your README.txt file.
You must use different recursive methods than those shown in the lecture notes, though the techniques can be the same. For instance, you will not get credit for turning in the drawTree() method. Also, using a Turtle is optional, but encouraged.
- You must include your name in the drawing using anti-aliased text.
- Each shape (or text) must be drawn in its own method. For example, you would put the code to draw lines in a method like:
public void drawLines(Graphics g) {
// code to draw lines here
}
- To your
MyDrawing class, add a main() method that displays the drawing. Your drawing must display and run to completion without any user input.
- Do not use any
package statements.
- Make an executable JAR of your program containing all the files described in the section of this document: What to Turn In.
Sample Drawing

Also, you can download and run the asn10demo JAR file. Notice that you can run graphics programs from JAR files by double-clicking the JAR file.
^ top
Extra Credit
Adding the following are worth extra credit points:
- Use Java2D to fill shapes with gradients or textures. (1 point)
- Add a Koch snowflake fractal to your drawing. (1 point)
- Add a Sierpinski triangle fractal to your drawing. (1 point)
- Add a dragon curve fractal to your drawing. (1 point)
Make certain that your README.txt file describes any extra credit attempted.
^ top
Grading Criteria
The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.
Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.
For information on grading policies, including interpretation of scores, see the course information page.
Program Compilation
- 4: Source code compiles with no errors or warnings
- 2: Source code compiles with warnings
- 0: Does not compile or wrong file turned in
Functionality
- 10: Demonstrates mastery of the assignment
- Has extra features or demonstrates techniques beyond the assignment
- Applies concepts from the lesson(s) appropriately
- Meets all specifications (see above) with particularly elegant solutions
- No errors encountered during operation
- 8: Has all the functionality expected of the assignment
- Demonstrates many techniques from the lesson
- Meets all specifications (see above)
- Implementation seems more complicated than necessary.
- May have one minor error
- 6: Has most of the functionality expected of the assignment
- Demonstrates some techniques from the lesson
- Meets all but one of the specifications (see above)
- Implementation seems excessively complicated.
- May have 2-3 minor errors
- 4: Has some of the functionality expected of the assignment
- Demonstrates some techniques from the lesson
- Meets at least 1/2 of the specifications (see above)
- Implementation seems excessively complicated.
- May have more than 3 minor errors
- 2: Serious functional problems but shows some effort and understanding
- Meets less than 1/2 of the of the specifications (see above)
- Has a major error or many minor errors
- Implementation seems very convoluted
- Demonstrates few techniques from the lesson
- 0: Does not execute or no specifications met
Program Style
- 4: Code is well-documented
- 3: Code has minor documentation errors
- Has 1 documentation error
- 2: Code has some documentation errors
- Has 2-3 documentation errors
- 1: Code has many documentation errors
- Has more than 3 documentation errors
- 0: No apparent attempt to document code
REAME.txt File
- 2: README.txt file submitted with specified information included
- 1: README.txt submitted but some information was not included
- 0: No README.txt submitted
Maximum Score: 22, plus extra credit
^ top
What to Turn In
Submit your assignment following the instructions for homework. Include the following items for grading:
README.txt file
- All Java source code and class files in a single executable JAR file
You must submit all the files needed for your assignment to compile and work correctly. Do not assume that the instructors has any files. Also, do not turn in files that are not part of your assignment, especially ones that do not compile. Your assignment must compile after removing all the .class files and running: javac *.java. In addition, your code must work as submitted.
^ top
Home
| Blackboard
| Schedule
| Room Policies
| Syllabus
Help
| FAQ's
| HowTo's
| Links
Last Updated: May 09 2010 @22:30:20
|