Use Case Name: Start airplane simulation
Scope: Airplane Flight Simulator
Level: User goal
Primary Actor: User
- User starts Airplane simulator
- Ask the user for a maximum height(ceiling)
- Ask the user for a minimum height(floor)
- Airplane simulator begins from an airborne position, no takeoff or landing
- Airplane ascends to maximum height
- Airplane descends to minimun height
- Repeate steps 5 and 6, until user ends simulation
Here is my question. In .NET, which Timer best fits the Airplane class, should it be a Windows Forms timer, A server-based timer or a Threading Timer? I am trying to get the airplane to ascend/descend at a rate determined by the interval of the timer. Hope that makes sense.
I need some clarification on this, please help! Here is my class
using System; using System.Timers;
namespace ConsoleApplication1
{
class Airplane
{
public Airplane()
{
_currentAltitude = 0;
Timer _timer = new Timer();
_timer.Start();
Console.WriteLine("airplane started");
Console.ReadKey();
}
public const int MAXALLOWABLEHEIGHT = 30000;
public const int MINALLOWABLEHEIGHT = 15000;
private int _currentAltitude;
public int CurrentAltitude
{
get
{
return _currentAltitude;
}
set
{
_currentAltitude = value;
}
}
private bool airplaneIsDead = false;
// Define the delegate types
public delegate void GoneTooHigh(string msg);
public delegate void GoneTooLow(string msg);
// Define member variables of the above delegate types
private GoneTooHigh MaxHeightViolationList;
private GoneTooLow MinHeightVioloationList;
// Add members to the invocation lists using helper methods
public void OnGoneTooHigh(GoneTooHigh clientMethod)
{
MaxHeightViolationList = clientMethod;
}
public void OnGoneTooLow(GoneTooLow clientMethod)
{
MinHeightVioloationList = clientMethod;
}
void _timer_Elapsed(object sender, ElapsedEventArgs e)
{
if (_currentAltitude < MAXALLOWABLEHEIGHT)
{
_currentAltitude++;
}
else
{
_currentAltitude--;
}
}
}
}