Graphic
by Keith Ohlfs
|
CS111, Wellesley College, Fall
1997
Problem Set 2:
Something Fishy
Due: Monday, September 29, 6pm
|
[CS111 Home Page]
[Syllabus]
[Students]
[Lecture Notes]
[Assignments]
[Programs]
[Documentation]
[Software Installation]
[FAQ]
[CS Dept.]
[CWIS]
Elba Coor, the owner of Something Fishy (a chain of stores
that sells pet fish and pet fish supplies), is looking to increase
business through advertising. She thinks that a cute logo with clever
cartoon-like graphics will increase the visibility of his brochures,
newspaper ads, and web pages. So Elba has decided to hold a contest
for the best Something Fishy logo. A logo should have the
words "Something Fishy" and depict fish and fish-related supplies
(fishtanks, fish food, filters, etc.). The official rules of the
contest appear below. Entries will be judged based on technical
excellence, creativity, and humor.
Elba is also a big fan of computers, and has recently become
enthralled with Java. After attending the recent Java developers
conference in New York, Elba is convinced that all applications
should be implemented in "100% pure" Java. So Elba dictates that all
entries into her logo contest must be Java applets that draw a
picture using the methods of Java's Graphics class (e.g. drawLine, drawRect, fillOval, setColor, etc.). For example, here is a very
simple fish that was drawn by the code below:
public void paint(Graphics g)
{
// Draw the tail
g.setColor(Color.black);
Polygon tail = new Polygon();
tail.addPoint(10,20);
tail.addPoint(10,80);
tail.addPoint(50,50);
g.fillPolygon(tail);
// Draw the body
g.setColor(Color.red);
g.fillOval(15,30,200,40);
// Draw the eye
g.setColor(Color.white);
g.fillOval(180,40,10,10);
}
You are an aspiring Java programming apprentice whose mentors have
decided that Elba's contest is an excellent opportunity for you to
exercise your skills in Java graphics programming. Following the
rules to Elba's contest (below), you will submit your entry to the
contest by placing your entry folder into your ps2 drop folder by 6pm
on Monday, September 29. The entry folder should consist of the
following files:
- A Java source file named your-username_fishy.java that contains all your Java
code. This file should be a modified version of the
CS111Applet.java file.
- A Java bytecode file named your-username_fishy.class that is the result of compiling
your-username_fishy.java.
- An HTML file named your-username_fishy.html that invokes your-username_fishy.class
- A Symantec Cafe project named your-username_fishy.proj that contains your-username_fishy.java and your-username_fishy.html.
Rules to Elba Coor's Something Fishy Logo Contest
- The logo should contain all of the following elements:
- The words "Something Fishy".
- At least three fish. They may all have the same design, or
may look very different.
- Some indication of water (waves, bubbles, blue background,
etc.)
- At least two fish related-supplies (fishtanks, fishbowls,
fish food, filters, lights, plants, toys, etc.)
- Your picture should be drawn by a Java applet that is a
modification of the code in CS111Applet.java. The name of your class
should be your-username_fishy in place of CS111Applet.
- You may use any of the Java graphics methods listed on the
Graphics
contract page, but not additional methods listed in the
Graphics API. In addition, you may use
Color,
Font,
and
Polygon
methods.
- Your program will be judged not only by the graphical result
by also by the clarity of the Java code that produces that result.
Strive to make your code as readable as possible. In particular:
- Use indentation and comments to make your code more
readable. Short comments begin with the characters // and go to the end of the
line. Comments spanning more than one line can be included
between /* and */.
- Where possible, try to avoid long segments of straight-line
code by using methods to decompose the picture into meaningful
parts.
- Where possible, try to avoid "magic numbers" by giving
meaningful names to key values and calculating derived values.
- Prizes will be awarded in the following categories:
- technical Excellence
- creativity
- humor
If you feel that the constraints in Rule #1 cramp your creativity,
you are welcome (but not at all required!) to submit more than one
logo. Only one submission needs to satisfy the constraints of Rule
#1; the others can contain whatever you want.