C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 9th, 2008, 01:30 AM
!makes_sense !makes_sense is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 7 !makes_sense User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 29 m 19 sec
Reputation Power: 0
General - Lunar Lander Program

I have been working on my Lunar Lander program, but I have few problems that need to be solved.

First here are the program requirements:



SPECIFY, DESIGN, and IMPLEMENT a CLASS that can be used to simulate a Lunar Lander, which is a small spaceship that transports astronauts from lunar orbit to the surface of the moon.

Then, Write a PROGRAM using that class to implement a Lunar Lander game - allowing the user to interact with the Lander, attempting to achieve a safe lunar landing.

Here is a sample run: assign5sample.htm

When a Lunar Lander is constructed, the following items should be specified, with default values as indicated:

* Current fuel flow rate as a fraction of the maximum fuel flow (default zero)
* Vertical velocity of the lander (default zero meters/sec)
* Altitude of the lander (default 1000 meters)
* Amount of fuel (default 1700 kg)
* Mass of the lander when it has no fuel (default 900 kg)
* Maximum fuel flow rate (default 10 kg/sec)
* Maximum thrust of the lander's engines (default 5000 newtons)

Don't worry about other properties.

The lander has accessor member functions that allow a program to retrieve the current values of any of the seven items listed above.

There are two mutator functions:

* A function that changes the current fuel flow rate to a new range from 0.0 to 1.0 - this is expressed as a fraction of the maximum fuel flow.
* A function that simulates the passage of a small amount of time. This time, t, is expressed in seconds, and typically will be a small value such as 0.1 seconds. The function will update the first four data values in the above list, to reflect the passage of t seconds.

The following formulas are approximations, which are reasonably accurate over a small period of time:

* Fuel flow rate: Normally does NOT change during this time - UNLESS the flow rate is greater than zero, and the amount of fuel is zero, then reset the rate to zero.
* Velocity change: The velocity of the lander will change approximately to: Velocity = Velocity - t * (f/m - 1.62) where m = total mass of the lander, and f = the thrust of the engines (calculated as the current flow rate times the max thrust), and 1.62 is the downward acceleration from gravity on the moon
* Altitude change: Altitude = Altitude - t * v where v = vertical velocity of the lander
* Fuel is reduced by: Fuel = Fuel - t * r * c Where r = current flow rate, and c = maximum fuel flow rate

It is suggested that you calculate the changes in the order listed. After these adjustments, two other things need to be done:

* If the altitude is less than zero, set it to zero - unless you want to calculate the depth of the hole you just created!
* If the remaining fuel goes below zero, set it to zero.

Your PROGRAM should then use this class, and allow the user the opportunity to specify beginning values for the data items, and be asked for periodic updates for the current fuel flow rate. (You might have the user enter a number from 0 to 10 for the flow rate, and then internally divide by 10, and use that as the flow rate.)



Here is what the sample output should look like:



LUNAR LANDER GAME

Lets Play!!!



Enter a number (1 to 7) to change values, S to Start the Game or Q to Quit



Choose a number to change the default values shown in ( ):



Fuel Flow Rate ( 0 ) : 1

Vertical Speed ( 0 meters/sec) : 2

Altitude ( 1000 meters) : 3

Amount of Fuel ( 1700 kg) : 4

Mass without Fuel ( 900 kg) : 5

Max. Fuel Consumption Rate ( 10 kg/sec) : 6

Max. Thrust ( 5000 newtons) : 7

Start the Game : S

Quit the Game : Q



Enter your choice : 3

Altitude Value in meters : 345



Choose a number to change the default values shown in ( ):



Fuel Flow Rate ( 0 ) : 1

Vertical Speed ( 0 meters/sec) : 2

Altitude ( 1000 meters) : 3

Amount of Fuel ( 1700 kg) : 4

Mass without Fuel ( 900 kg) : 5

Max. Fuel Consumption Rate ( 10 kg/sec) : 6

Max. Thrust ( 5000 newtons) : 7

Start the Game : S

Quit the Game : Q



Enter your choice : s

Lunar Lander Created



Current Speed :0.162

Current Altitude :344.984

Current Fuel :1700



Current Speed :0.324

Current Altitude :344.951

Current Fuel :1700

.......

.......

.......



Current Speed :8.1

Current Altitude :324.345

Current Fuel :1700

Change Fuel Flow Rate (0 - 10) ? (Y or N) :Y



Fuel Flow Rate Value in the range of 0 - 10: 5



Current Speed :8.16585

Current Altitude :323.528

Current Fuel :1699.5



Current Speed :8.23168

Current Altitude :322.705

Current Fuel :1699

.......

.......

.......



Current Speed :56.6999

Current Altitude :4.91532

Current Fuel :1700

Change Fuel Flow Rate (0 - 10) ? (Y or N) :n



Current Speed :56.8619

Current Altitude :0

Current Fuel :1700

Lunar Lander has stopped.

Explosion!! Altitude is 0, Speed is not 0!!

You lost...Bye


My question is how do I change the values of altitude, velocity and other variables when they are originally set to default values.

I have already written the accessor functions for altitude, velocity, etc but I don't think they can change a default value.

Any ideas?

Reply With Quote
  #2  
Old June 10th, 2008, 05:17 AM
MaHuJa's Avatar
MaHuJa MaHuJa is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Dec 2007
Posts: 1,177 MaHuJa User rank is Private First Class (20 - 50 Reputation Level)MaHuJa User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 21 h 27 m 36 sec
Reputation Power: 12
Send a message via Skype to MaHuJa Send a message via XFire to MaHuJa
According to google, define:default
A default, in computer science, refers to a setting or value automatically assigned to a computer program or device, outside of user intervention. Such settings are also called presets, especially for electronic devices.
en.wikipedia.org/wiki/Default (computer science)
(My emphasis)

Default values are what the values are before they are changed. They are not constants (in c++ marked with the keyword const).

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > General - Lunar Lander Program


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap