Mars Lander: A 1-Player Game

BIT 143 – ASSIGNMENT 1

Due Date: < Listed in the course schedule >

           

            You are not allowed to work in groups this assignment.  For this assignment, you should start, finish, and do all the work on your own.  If you have questions, please contact the instructor.

 

           


 

This assignment should be doable within the time-frame given.  If you find yourself having difficulty, please seek out extra help from the instructor.

 

Write a text-based version of a 1-player game called Mars Lander by filling in the missing parts of the provided starter project. In this game, the player is trying to land a space ship on Mars without crashing into the planet.  The player starts with 500 fuel points, and on each turn, the player decides how many fuel points to have the rocket engines burn.  The more fuel that's burned, the greater the effect on the Mars Lander's speed, as it falls towards Mars. The Lander starts at a distance of 1,000 meters above the surface of the planet, and in order to safely put the lander on Mars, it must reach the surface of Mars, and be traveling at no more than 10 meters/second when it does so.

 

Each round, you need to print out a visual depiction of how far above the surface the lander is, using an asterisk ( * ) as the space ship.  You need to also tell the player how many fuel points are left, and the current (downward) speed of the spaceship, and the exact height of the ship. 

 

Additionally, the program must print out a list of the heights and speeds that the lander was travelling at, at the start of each round.  You are not allowed to use a ‘pre-fab’ class from the .Net library (such as the List class).

 

In order to keep this somewhat simple, we'll use the following formulas to determine the speed of the Mars Lander (in meters/second).

 

The speed in the next round will be equal to
the speed in the current round
            plus 50 meters/second
            minus
(the number of fuel points burned) multiplied by 1 meter/second)

 

In other words, the spaceships accelerates at the (admittedly inaccurate) constant velocity of 50 m/s, minus however many fuel points the player burns.  Note that if the player burns enough fuel, the spaceship may actually end up going upwards.  This is fine, and should be something that the program can accommodate.

 

The "Examples Of Play" at the end of this assignment should demonstrate how the game should be played, and demonstrates a couple of key points:

·         The new speed should be calculated, THEN the spaceship decends that much

·         In the graphical display of the height, the star goes next to the smallest height that the spaceship is higher than.  So if the spaceship is actually at 805 meters above the ground, put the * next to "800 m."  If it's 799 meters up, then put the * next to the "700 m"

·         You need to make sure that your player has entered a valid number for the number of fuel points they want to burn – no more than what they've got, no less than zero.

·         You can't assume that the player always types numbers, so you will have to check for the player typing in their name, or anything else, rather than a number.  You should make use of the TryParse command to handle this sort of user input error.

 

Remember to follow good programming practices - meaningful variable names, proper indentation and spacing of blocks of code, documentation where necessary. Put your name and a description of the program in comments at the top of the program.

 

            Object Composition: Your program needs to substantially utilize at least two classes in order to accomplish the above goals.  Each class must have non-trivial functionality (i.e., you can't just have a Program class that kicks off a Game.PlayGame method, and have the PlayGame method do all the work for the program).  The starter project that you should download from the website is set up so that it already contains several classes, and so it's recommended that you simply use these classes by filling in the missing pieces with your code. 

 

            Separation of User Interaction: You need to limit the number of classes that interact with the user.  There should be only one class that will handle most of the user interaction (printing menus, getting all input from the user, etc, etc).  The goal here is that if you decided to use a different user interface (ASP.Net, or maybe moved the program to XNA/XBox), you could keep all the code the same, except for that one class that uses the Console to interact with the user. 

The project: contains brief explanations of the classes that make up the project, in comments inside the project.  There's an overview in the main function of the program.

 

Group Work, Commenting:

 

           

            You are not allowed to work in groups this assignment.  For this assignment, you should start, finish, and do all the work on your own.  If you have questions, please contact the instructor.

 

           

 

            Additionally, you should comment your code, paying particular attention to areas that are difficult to understand.  If you found something to be tricky when you wrote it, make sure to comment it so that the next person (the instructor, who's grading you) understands what your code is doing.  It is not necessary to comment every single line.

 

The purpose of new requirement is to both help you understand, and have you demonstrate, a thorough understanding of exactly how your program works.

 

Every file that you turn in should have:

·         At the top of the file, you should put your name (first and last), the name of this class (“BIT 143”), and the year and quarter, and the assignment number, including the revision number, which starts at 0 (“A1.0”).  If you’re handing this in again for a regrade, make sure to increase the minor version number by one (from “A1.0”, to “A1.1").

 

In general, you should make sure to do the following before handing in your project:

·         All variables used should have meaningful names.

·         The code should be formatted consistently, and in an easy to read format.   

 

What to turn in:

 

o   The C# source code for the entire program. 
Please include all the .CS files, whether you've changed them or not, just on the off chance you forgot that you changed them.

 

How to electronically submit your homework:

 

This was covered in a separate document in this website..


Examples Of Play:

Here are two demonstrations of how the game should look . The * represents the Mars Lander, and user input is given in bold.

 

Unsuccessful Landing:


Welcome to the Mars Lander game!
1000m: *
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 1000 meters
Current (downward) speed: 100 meters/second
Fuel points left: 500

How many points of fuel would you like to burn?
500

1300m: *
1200m:
1100m:
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 1350 meters
Current (downward) speed: -350 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0

1600m: *
1500m:
1400m:
1300m:
1200m:
1100m:
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 1650 meters
Current (downward) speed: -300 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0
1900m: *
1800m:
1700m:
1600m:
1500m:
1400m:
1300m:
1200m:
1100m:
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 1900 meters
Current (downward) speed: -250 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0
2100m: *
2000m:
1900m:
1800m:
1700m:
1600m:
1500m:
1400m:
1300m:
1200m:
1100m:
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 2100 meters
Current (downward) speed: -200 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0

2200m: *
2100m:
2000m:
1900m:
1800m:
1700m:
1600m:
1500m:
1400m:
1300m:
1200m:
1100m:
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 2250 meters
Current (downward) speed: -150 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0

2300m: *
2200m:
2100m:
2000m:
1900m:
1800m:
1700m:
1600m:
1500m:
1400m:
1300m:
1200m:
1100m:
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 2350 meters
Current (downward) speed: -100 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0

2400m: *
2300m:
2200m:
2100m:
2000m:
1900m:
1800m:
1700m:
1600m:
1500m:
1400m:
1300m:
1200m:
1100m:
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 2400 meters
Current (downward) speed: -50 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0
2400m: *
2300m:
2200m:
2100m:
2000m:
1900m:
1800m:
1700m:
1600m:
1500m:
1400m:
1300m:
1200m:
1100m:
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 2400 meters
Current (downward) speed: 0 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0

2300m: *
2200m:
2100m:
2000m:
1900m:
1800m:
1700m:
1600m:
1500m:
1400m:
1300m:
1200m:
1100m:
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 2350 meters
Current (downward) speed: 50 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0
2200m: *
2100m:
2000m:
1900m:
1800m:
1700m:
1600m:
1500m:
1400m:
1300m:
1200m:
1100m:
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 2250 meters
Current (downward) speed: 100 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0

2100m: *
2000m:
1900m:
1800m:
1700m:
1600m:
1500m:
1400m:
1300m:
1200m:
1100m:
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 2100 meters
Current (downward) speed: 150 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0

1900m: *
1800m:
1700m:
1600m:
1500m:
1400m:
1300m:
1200m:
1100m:
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 1900 meters
Current (downward) speed: 200 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0
1600m: *
1500m:
1400m:
1300m:
1200m:
1100m:
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 1650 meters
Current (downward) speed: 250 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0

1300m: *
1200m:
1100m:
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 1350 meters
Current (downward) speed: 300 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0

1000m: *
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 1000 meters
Current (downward) speed: 350 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0

1000m:
900m:
800m:
700m:
600m: *
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 600 meters
Current (downward) speed: 400 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0

1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m: *
0m:

Exact height: 150 meters
Current (downward) speed: 450 meters/second
Fuel points left: 0

How many points of fuel would you like to burn?
0

The maximum speed for a safe landing is 10; your lander's current speed is 500
You have crashed the lander into the surface of Mars, killing everyone on board,
costing NASA millions of dollars, and setting the space program back by decades!
Here's the height/speed info for you:
Round # 	Height (in m) 	Speed (downwards, in m/s)
0 		1350 		-350
1 		1650 		-300
2 		1900 		-250
3 		2100 		-200
4 		2250 		-150
5 		2350 		-100
6 		2400 		-50
7 		2400 		0
8 		2350 		50
9 		2250 		100
10 		2100 		150
11 		1900 		200
12 		1650 		250
13 		1350 		300
14 		1000 		350
15 		600 		400
16 		150 		450
17 		0 		500

 

 

Successful Landing:


Welcome to the Mars Lander game!
1000m: *
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 1000 meters
Current (downward) speed: 100 meters/second
Fuel points left: 500

How many points of fuel would you like to burn?
0
1000m:
900m:
800m: *
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 850 meters
Current (downward) speed: 150 meters/second
Fuel points left: 500

How many points of fuel would you like to burn?
0
1000m:
900m:
800m:
700m:
600m: *
500m:
400m:
300m:
200m:
100m:
0m:

Exact height: 650 meters
Current (downward) speed: 200 meters/second
Fuel points left: 500

How many points of fuel would you like to burn?
0
1000m:
900m:
800m:
700m:
600m:
500m:
400m: *
300m:
200m:
100m:
0m:

Exact height: 400 meters
Current (downward) speed: 250 meters/second
Fuel points left: 500

How many points of fuel would you like to burn?
0
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m: *
0m:

Exact height: 100 meters
Current (downward) speed: 300 meters/second
Fuel points left: 500

How many points of fuel would you like to burn?
300
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m: *

Exact height: 50 meters
Current (downward) speed: 50 meters/second
Fuel points left: 200

How many points of fuel would you like to burn?
example non-numeric input
You need to type a whole number of fuel points to burn!

Just as a reminder, here's where the lander is:
Exact height: 50 meters
Current (downward) speed: 50 meters/second
Fuel points left: 200

How many points of fuel would you like to burn?

300
You don't have 300 points of fuel!

Just as a reminder, here's where the lander is:
Exact height: 50 meters
Current (downward) speed: 50 meters/second
Fuel points left: 200

How many points of fuel would you like to burn?

-100

You can't burn less than 0 points of fuel!

Just as a reminder, here's where the lander is:
Exact height: 50 meters
Current (downward) speed: 50 meters/second
Fuel points left: 200

How many points of fuel would you like to burn?

52

1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m: *

Exact height: 2 meters
Current (downward) speed: 48 meters/second
Fuel points left: 148

How many points of fuel would you like to burn?
90
 
How many points of fuel would you like to burn?
90
1000m:
900m:
800m:
700m:
600m:
500m:
400m:
300m:
200m:
100m:
0m: *

Exact height: 0 meters
Current (downward) speed: 8 meters/second
Fuel points left: 58
Congratulations!! You've successfully landed your Mars Lander, without crashing!!!
Here's the height/speed info for you:
Round # 	Height (in m) 	Speed (downwards, in m/s)
0 		850 		150
1 		650 		200
2 		400 		250
3 		100 		300
4 		50 		50
5 		2 		48
6 		0 		8