CSE 8B: Introduction to Computer Science: Java (Winter, 2006)

Home | Syllabus | Schedule | Exams | Programming Assignments

Programming Assignment 8

Due Monday, March 13 at 11:59 PM.

Overview

You'll be writing a Lunar Lander arcade game

The main class will be LunarLanderUI. You'll run it with:

java LunarLanderUI

A sample can be found in ~/../public/P8/LunarLanderUI.jar. Run it with

java -jar ~/../public/P8/LunarLanderUI.jar 
Note that this sample gives an idea of what needs to be done, but doesn't follow the requirements in detail. Press the spacebar to fire the engines; release to turn off the engines. Press the escape key to start a new game.

Lunar lander is a game with a spacecraft with a certain amount of fuel trying to land on the moon. The object of the game is to land the craft safely (not exceeding some maximum velocity) without running out of fuel.

In the actual arcade game, you could control both the throttle, as well as rotate the spacecraft so as to move horizontally. In our version of the game, there is no rotation; the only control is the throttle. (See this on-line Lunar Lander game for an idea of what the arcade game looks like).

We give you the physics of the game in a class called LunarLander. It handles keeping track of gravity, fuel remaining, mass of the lander, impulse of the fuel (how much oomph it gives), height and velocity of the lander, and whether or not the lander has landed, or crashed.

However, the LunarLander class is not a model because it doesn't notify observers of changes. Your first task will be to make the LunarLander class a model.

Requirements

The program will need to:

Provided files

All files are in ~/../public/P8.

There is a sample implementation of this application in a jar file: LunarLanderUI.jar.

The file LunarLander.java contains the class that handles the physics. There's a unit test TestLunarLander.java that tests LunarLander.java. Use it to help see how to use the class (and verify that it works).

Hints

Turnin

Create a directory on ieng6 with the following files: To turn in your assignment, cd to that directory and run the command
  bundleP8
If it is before the due deadline and all necessary assignment files are present, this will turn in your solution files. You can run bundleP8 more than once if you want; only the last one will count.

Grading

We'll be running your program and trying it out on ieng6, so make sure you've tested your app there.

The assignment is worth 20 points.

As always, an additional 5% (1 point) is available if you turn the assignment in at least 24 hours early.

Extra credit points of up to 4 points are available for significant additions to the game. Possibilities include: