CS 201 - Computer Science I - Fall 2008
Project 2
Loyola College >
Department of Computer Science >
Dr. James Glenn >
CS 201 >
Projects >
Project 2
Due
Monday, October 27th at 11:59pm.
Projects submitted after the due date will be assessed a 20% penalty per day.
Projects will not be accepted more than four days late.
Objectives
- to instantiate objects
- to invoke methods
- to understand API documentation
Introduction
This applet requires Java 2 and so will not work with some browsers.
Use the arrow keys to guide your frogs home.
The goal of Calaveras Crossing is to navigate your frogs across the road and
river into the niches at the top of the screen. Along the way, you must
avoid getting your frogs squished in traffic or drowned in the river.
The game ends when you have filled all five niches or killed three frogs.
Assignment
Create a Calaveras Crossing level. To do this, you must work with the
Level, Lane, Log, Turtles,
Truck, Car, Racecar, and Tractor classes.
Documentation, but not source code, is
provided for those classes. (Note that there is documentation for classes
you will not work with directly, and even in the documentation for the classes
you are using directly there are many methods you will not use directly.)
The Lane class represents a horizontal lane of traffic, whether
it is road traffic or river traffic. The Level class represents
the collection of lanes players navigate their frogs across. All of the
other classes listed above represent the various obstacles the frog may
encounter. Note that there are currenly no differences between
Tractor, Car, and Racecar; you should
use these classes for slow, medium, and fast small vehicles and we
will make cosmetic changes in Project 3.
In general, to create a level you will instantiate several Lanes,
instantiate various obstacles, add them to the lanes using the
appropriate method, and then add the lane to the level using the appropriate
method. Certain attributes of the obstacles and lanes (speed, width, etc.)
can also be set, either by passing arguments to their constuctors when
they are instantiated, or by invoking their methods.
Make sure the level you create meets the criteria listed below in the
grading section.
Note that horizontal positions and widths are given in terms of the
width of the screen: 1.0 for a width means as wide as the screen; 0.25
for a horizontal position means 1/4 of the way from the left edge to the
right edge of the screen. The frog, for example, is 0.1 wide (1/10 of the
screen).
Files
The archive file calaveras.jar contains
compiled .class files only. Extract the .class files using jGRASP's
Jar/ZIP extractor just like you would extract .java files.
To understand how to use the classes in
the archive, see the documentation.
Your code to instantiate levels, lanes, and obstacles goes in
CalaverasCrossingWindow.java. To
play the game, compile and run that file.
There was a logic error in the original Frog class that prevented
your frog from respawning when it floated off the edge of the screen. That
error has been corrected. The current version of the archive has the corrected
code. You can also download just the single file
Frog.class (make sure to save it in the same
directory as your other P2 files).
Advice
- As always, write your code incrementally. You might want to start
with a single road lane with no vehicles. Then add vehicles one
by one and set the velocity of the lane. Once you have written the
proper code for one lane it will be easier to write the code to set
up the other lanes.
Grading
- Correct and complete use of provided classes: 70%;
for full credit you must do the following:
- create at least 8 lanes that are not empty lanes of grass;
- create at least one convoy of at least three vehicles following
immediately after each other;
- use groups of turtles of at least two different sizes;
- use at least two groups of diving turtles, one with the default
dive time and one with a different dive time;
- use at least one row of evenly spaced logs;
- use at least one row of unevenly spaced logs;
- include lanes moving in both directions;
- include at least one lane that is wider than the screen; and
- include at least one lane that moves at the maximum speed.
- Creativity: 10%
- Comments and Style: 20% (you must make a good faith effort towards correctness to earn this part of the grade)
- Whistling: 0% (whistle Ino No Omawarisan while playing the game)
Submissions
Submit by e-mail the source code (.java file) for your edited version
of CalaverasCrossingWindow.java.