This assignment is to be done individually without your teammate. You can talk to other people in the class (including your teammate), me (Dave), the prefects, and lab assistants for ideas and to gain assistance. You can share ideas and help each other debug programs, if you wish. The code that you write should be your own, however, and you shouldn't hand a printout of your program to others. See the course syllabus for more details or just ask me if I can clarify. OverviewComputer simulation is used by engineers to test out ideas before actually building expensive machines or putting people in dangerous situations. Simulation is a critical part of the the space program by NASA, for example. For this program, you will create a simulation of a vehicle landing on the moon. (It turns out that this assignment is also a rather old computer game that has been around for decades.) Here is how it works: You are in control of a lunar lander ship, descending to the surface of the moon for a landing. Gravity steadily accelerates your ship faster and faster toward the surface of the moon. You, the astronaut piloting the ship, have a single control: a button with the label "thrust" on it. Applying thrust slows your ship down. Your goal is to get your ship to land on the moon at a slow enough speed so that it doesn't crash on impact. What's the catch? You have only a limited amount of fuel. If you slow down your ship too much too early, you will run out of fuel and crash into the surface of the moon. Your mission: Program this simulation in Java. DetailsYou should create two classes: LunarLander, and Simulation. The LunarLander class represents the ship itself, and is the class that you will create an object from. The Simulation class is the one that has the main method in it, and controls how the simulation works. In your LunarLander class, you will need to keep the following information in instance variables:
Your LunarLander object should have the following methods (you may have more if you wish):
Your Simulation class should have one method: public static void main(String[] args). This method should create a LunarLander object, provide the player with a welcome message, then repeatedly show the player the current information for the lander followed by a question as to how many units of thrust to burn. If the lander ends up hitting the surface of the moon with a velocity of 4 meters/second or less, the ship lands successfully! If the lander hits the surface with a velocity of 5 meters/second or more, the ship crashes. You'll find a sample game at the bottom of this assignment. Parts 1 and 2This assignment is broken into two parts to help you pace yourself, since it is bigger than previous assignments. Part 1 should have at least:
Part 1 is worth a total of 5 points. Part 2 should, of course, finish the assignment. You are welcome to turn in more than the minimum for Part 1, including the complete assignment, at the first deadline if you like. The brunt of the work is probably in Part 2, not Part 1, so if you have more time to work on Part 1 than Part 2, you should probably go further ahead. In my mind, the part of the assignment I have allocated to Part 1 is a "bare minimum" to keep you from being overburdened later. Part 2 is worth 20 points. Bonus workIf you achieve everything specified in this assignment for Part 2, you will receive 19 points out of 20, which is to be congratulated! In my mind, that means that you've done wonderful work, and you've satisfied my expectations. If you want the 20th point: create an alternative simulation class called SimulationRace that is very similar to Simulation but has two LunarLander objects descending to the moon, each controlled by different users. The two players alternate back and forth entering thrust for their own landers, until one them lands or until they both crash. I'm leaving the specifications of this fairly vague: get something working that involves two players with two landers working successfully, and you'll earn your point. Hints, Suggestions, Etc.
Here is a sample simulation:
|
|
Moodle Docs for this page