|
| Encylopedia
Astronautica |
Test your LunarLander class completely. I recommend creating a test method to do so, just like we did with previous assignments. Make sure that all your LunarLander methods work as they should.
- Expend fuelUnits of fuel from the fuel tank. Make sure you check to see if you actually have this much fuel. If not, burn the rest of it.
- For each of unit of fuel that you burn, call the thrust() method to decrease your velocity.
- Determine the new altitude for your lander. Your new altitude is your old altitude plus your velocity, plus an additional 2 meters/second for gravity. Gravity adds 2 meters/second to your velocity every second.
| Welcome to Lunar Lander! Alt = 1000 Vel = 40 Fuel = 25 How much thrust this round? 0 Alt = 958 Vel = 42 Fuel = 25 How much thrust this round? 0 Alt = 914 Vel = 44 Fuel = 25 How much thrust this round? 0 Alt = 868 Vel = 46 Fuel = 25 How much thrust this round? 0 Alt = 820 Vel = 48 Fuel = 25 How much thrust this round? 0 Alt = 770 Vel = 50 Fuel = 25 How much thrust this round? 0 Alt = 718 Vel = 52 Fuel = 25 How much thrust this round? 0 Alt = 664 Vel = 54 Fuel = 25 How much thrust this round? 0 Alt = 608 Vel = 56 Fuel = 25 How much thrust this round? 0 Alt = 550 Vel = 58 Fuel = 25 How much thrust this round? 0 Alt = 490 Vel = 60 Fuel = 25 How much thrust this round? 0 Alt = 428 Vel = 62 Fuel = 25 How much thrust this round? 0 Alt = 364 Vel = 64 Fuel = 25 How much thrust this round? 0 Alt = 298 Vel = 66 Fuel = 25 How much thrust this round? 0 Alt = 230 Vel = 68 Fuel = 25 How much thrust this round? 0 Alt = 160 Vel = 70 Fuel = 25 How much thrust this round? 2 Alt = 96 Vel = 64 Fuel = 23 How much thrust this round? 0 Alt = 30 Vel = 66 Fuel = 23 How much thrust this round? 0 Alt = -38 Vel = 68 Fuel = 23 Oh no, you crashed! |