CSCI 235 Spring 2015
Data Structures and Software Design
Archived Class
Charles Cusack
Computer Science
Hope College
Main
Schedule
Grading
Gradebook
Homework
Links

Policies
College
    Policies
Advice

Notes
Programs
Tutorials

CSCI 125
CSCI 255
MATH 131 (01 and 02)
Others

Admin

Homework 4

Details

The assignment in brief

  • Copy/Checkout the BlankPicture project from the SVN repository (We'll do this in class).
  • Draw a picture by modifying the PicturePanel class.
  • Commit your changes to the SVN repository from time to time. Refer to the SVN and Eclipse Examples as needed.
  • Modify index.html by changing the title and (if necessary) the width and height.
  • Fill in the MyGrade.txt file. Specify the score you think you earned in each category and briefly justify.
  • Hand in all of your java and class files (including the ones with symbols and numbers in the name), index.html, and MyGrade.txt using Webhandin under assignment 235-HW4. You can submit the files separately or put them in a zip file (with no directories--just the files) and submit that.
  • Go to the Student Solutions page and verify that your code is there and that your applet runs.
Purpose
The purpose of the first assignment is to
  • Help you refresh your memory on Java programming
  • Familiarize yourself with the Eclipse IDE (integrated development environment),
  • Learn how to use the Java API (application programming interface).
There is not a serious design component to this assignment, and at the surface it does not appear to be closely related to the main concepts of the course. However, it is meant to be a fun assignment to get you back into the swing of Java programming, and it turns out it does have a little to do with a few of the topics we will talk about.
Assignment
For this assignment you need to finish the implementation of the class PicturePanel.java that draws a picture. I will let you decide exactly what you want to draw, but be creative. You can draw a picture of yourself, your dog, a car, a park, etc. Your drawing should be a reflection of yourself. I can help you brainstorm ideas if necessary.

At a minimum, you should:

  • Have at least several dozen objects (circles, lines, text, etc.). This does not include stuff drawn in loops. In other words, you should have at least 24 statements in your code like drawOval, fillRect, etc.
  • Utilize several colors.
  • Have some text, including your name in the lower right corner. Use different fonts and styles.
  • Use several loops, and at least one nested loop (That is, a loop within a loop) to draw something.
  • Use at least a few if-then-else statements.
  • Use an array, ArrayList, or another simple data structure.
  • Use at least two methods.
  • React to at least 2 different mouse events. It does not count to react to "clicks" with both mouseClicked and mousePressed. Use another interaction like dragging. (Note: There are two sorts of mouse events: MouseEvents and MouseMotionEvents. See below for more about these.)
  • Create one or more new classes (not including listeners).
The more different sorts of objects you use, the better. Your grade will be based not only on how creative you are, but how much effort you put into learning some things about the various parts of the Java API mentioned below. An assignment which meets the expectation will receive 24/30. Scoring higher than this will require you to go beyond the minimum requirements.

If you have some prior experience with Java, or learn quickly, try to make your applet fancy with animation, or adding some functionality. For instance, you can ask the viewer to input some information, and modify the drawing based on the input.

You should not use BlueJ for this project. Use Eclipse instead.

Make sure to update the documentation. Remove my helpful comments and add appropriate comments to each class and method, using Javadoc-style comments. Also add inline comments within longer methods to describe what portions of your code are doing.

Resources
  • Several examples I and previous students wrote
    • BlankPicture The starting code. You will actually get it from elsewhere (SVN), but can also see it by following the link. This includes two classes (and perhaps a few other files which you can sefely ignore.
      • PictureApplet is the main class which allows you to run the program as an applet or application. You should not need to modify this class.
      • PicturePanel is the class that does the drawing, and you should certainly modify this one!
    • Past Solutions (including mine)
    • TimerExample A simple example of using a timer to do animation.
  • Java API
    Here are the classes that will be of most interest to you for this assignment.
    • Graphics The main class you will be interested in. You draw using the methods from this class.
    • Color A class you may be interested in if you want to create your own colors.
    • Font A class you may be interested in if you want to do anything fancy with Fonts.
    • MouseMotionListener An interface for mouse motion events
    • MouseListener An interface for mouse events
    • MouseAdapter An adapter that implements the MouseListener interface. Extend this class as a way to handle mouse events. Simply override any of the 5 methods to have it react the way you want.
    • MouseEvent The event passed to the MouseAdapter/MouseListener. Notice it allows you to determine the x and y coordinates of the mouse position, which button was clicked, etc.
  • Java Fonts A simple applet that shows you what certain fonts look like in Java. You might find it useful.
  • Google (link includes a sample search). Search for whatever you need help with. For instance "Java fonts" or "java font choices" or "java create colors", etc. When I am looking for a java class, I search for "java blah 6" (If the class is "blah") and the first hit is usually the API for that class (The "6" ensures I get the documentation for Java 6 instead of 1.4.2 or 5 or 7).
Grades
Grades will be based on the following chart. See the Grading page for how to interpret these categories.
CriteriaPointsDetails
Correctness10Each requirement met (8) and it runs (2)
Style6Reasonable variable/method names, methods make sense, and code formatting (2 each)
Documentation6The class, each method, and code is documented (2 each)
Learning Gains8Used classes, made an elaborate drawing, included extra events and methods (especially if it involved keyboard and other event types), used other new things (2 each)
Total30
Handing it in
  • Don't forget to hand in:
    • All of your java files
    • All of your class files, including those with $s in the name.
    • index.html, modified as necessary.
    • MyGrade.txt with your self-assessment.
  • Remember to submit with Webhandin under assignment 235-HW4.
  • Go to the Student Solutions page and verify that your code is there and that your applet runs.