| Homework 4DetailsThe assignment in brief
- Fork and clone the project into Eclipse:
- Fork the repository at https://bitbucket.org/ferzle/blankpicture
by logging into your BitBucket account, going to the URL above,
clicking the large + on the left side of the page and selecting
Fork this repository.
Change the name to something like Smith Picture, where you replace
Smith with your name. Make sure to click the box for
This is a private repository, and click Fork repository.
- Import it into Eclipse:
Click File-->Import..., select Git-->Projects from Git, then choose Clone URI, enter the URL
from YOUR fork of the project
(which you can get by clicking the Clone link) in the URI field,
and click Finish.
- Draw a picture by modifying the PicturePanel class.
- Commit your changes back to BitBucket from time to time.
- Change the width and height of the window (if you want)
and the title on the frame (this you should change) near the top of InteractivePicture. You should make no other changes to that file.
- Fill in the MyGrade.txt file. Specify the score you think you earned in each category and briefly justify.
- Zip up your entire project directory (probably called something like MyNamePicture, where MyName is your name).
- Hand in the zipfile using
Webhandin under assignment 235-HW4.
- If you did it correctly, it should say that you handed in various files
which should include MyGrade.txt and src among other files.
Make sure it lists at least those two.
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 must:
- 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).
- Change the title of the frame so it relates to your drawing.
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
application 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
-
Past Student Solutions
(including mine).
Several examples I and previous students wrote.
Download the file, unzip it somewhere on your computer, Open Eclipse, do File-->Switch Workspace and choose the directory you just unzipped.
Then do File-->Import, select General-->Existing Projects into Workspace, click Next, browse to select the directory you just unzipped.
A dozen or so projects show display in the window. Select Finish.
It should load a new workspace the dozen or so projects in Eclipse.
You can see the code and run them (Right-click their copy of InteractivePicture and select Run As--Java Application).
When you are done looking at them, you can switch back to your normal workspace.
- 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 (these link to the Java 6 versions of these classes,
but they should be not much different than the Java 7 or 8 versions).
- 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 8" (If the class is "blah") and the first hit is usually the API for that class (The "8" ensures I get the documentation for Java 8 instead of 1.4.2 or 7 or some other version).
Grades
Grades will be based on the following chart. See the Grading page for how to interpret these categories.
Criteria | Points | Details |
Correctness | 10 | Each requirement met (8) and it runs (2) |
Style | 6 | Reasonable variable/method names, methods make sense, and code formatting (2 each) |
Documentation | 6 | The class, each method, and code is documented (2 each) |
Learning Gains | 8 | Used 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) |
Total | 30 | |
Handing it in
- Zip up your entire project folder (Something like SmithPicture,
which should include the MyGrade.txt file (which you should fill out first!)
assuming you didn't do anything weird.
- Remember to submit with
Webhandin under assignment 235-HW4.
|
|
|