|
|
|
|||||||||||||||||
|
|
OverviewWeight: The homework will count 10% of your final grade.Due Date Monday, May 3, by 11:59 PM This assignment provides experience with language features of Java that we haven't encountered in previous languages: objects, exceptions, and threads to name a few. The goal is to write a simple game that lands a vehicle on a planet. The game will be implemented in two forms: a text-based game, playable in a terminal window, and a graphics game playable as an applet in a web browser. Turning in your projectAll code should be developed in thefour directory.
When you are done the directory will contain your source (java) files,
object (class) files, a transcript of a successful execution of the
text-based game, and the supplied gif and html files for the applet.
When you are done and certain that everything is working correctly,
create a zipped or tarred, gzipped copy of the four
directory.
Turn in the tar or zip file using
the turn-in page.
The uploaded file name should be four.tar.gz or four.zip.
You may turn in your assignment as many times as you like.
Getting startedA skeleton of the code for this assignment is provided. You can download the files in either four.tar.gz or four.zip. (This code has Unix/Linux line-ends so some Windows editors may not display it correctly -- Wordpad or any program editor should not have a problem.)GradingThe assignment will be marked for good programming style (indentation and appropriate comments), as well as clean compilation and correct function.Help with JavaThere is extensive documentation on Java on the web. The resources link on the class home page has links to only a few of the many, many resources available.Text based game - 75%The game package contains the classes for playing a planetary lander game. You may add other methods as you see fit to the classes indicated below.class PlanetAn instance of the Planet class models the physics of a planet. Edit Planet.java to implement this class. For this program, the physics is described by the gravity and the height of the surface. You are to write the following methods.
class RocketExceptionAn instance of this class is an exception thrown when the rocket reaches an undesirable state (e.g., it is below the surface without having landed and thus has crashed!). The exception should be thrown and handled appropriately by the methods of the other classes. You don't need to add anything to this class.class RocketAn instance of the Rocket class models the behavior of a rocket lander in the region of a planet. Edit Rocket.java to implement this class. The Rocket maintains the state of the rocket, which consists of a height, velocity, amount of fuel, engine strength, and the planet on which the rocket is landing. You may want to add additional state. I've set up the following methods for you to use.
class GameEdit Game.java to implement this class. This class actually plays the game by calling the appropriate methods in the Rocket class. The game is played by printing the position of the rocket, and the waiting for the user to input the character `b' indicating a full burn or anything else indicating no burn until the rocket either lands or crashes. When the game terminates, the rocket state and an appropriate message indicating whether the rocket has landed or crashed should be printed. Here is an example output of a game.
java Game
| * - 0.3
| * - 0.6
| * - 0.9
| * - 1.2
| * - 1.5
| * - 1.8
| * - 2.1
| * - 2.4
| * - 2.7
| * - 3
| * - 3.3
| * - 3.6
| * - 3.9
| * - 4.2
| * - 4.5
| * - 4.8
| * - 5.1
b
| * - 3.4
b
* - 1.7
b
*| 0
Landed Safely! One small step for man, one giant leap for mankind...
The above game was played on Pluto with a gravity of 0.3, the
surface at 0.0 and a rocket motor strength of 2.0.
Include in your tar or zip file a transcript of an interactive session in which you
play the game and land successfully. The game should be played
with the above Planet and Rocket attributes.
Good luck!
applet package -- 25%Modify the code in GameApplet.java to animate the applet. To view an applet useappletviewer my.htmlor open my.html in your browser (warning, may
not work for some versions of IE since Microsoft has removed support
for Java applets).
The applet will run the code in GameApplet.java.
There are at least three important methods that you will have to modify.
If you are into building GUIs you might want to investigate adding
components to the applet display that show dials for height, velocity
and remaining fuel. That would be visually more pleasant than displaying
text overlaid on the gif as is now done.
|
||||||||||||||||
| (c) 2003 Curtis Dyreson, (c) 2004 Carl H. Hauser E-mail questions or comments to Prof. Carl Hauser | ||||||||||||||||||