CATEGORII DOCUMENTE |
Asp | Autocad | C | Dot net | Excel | Fox pro | Html | Java |
Linux | Mathcad | Photoshop | Php | Sql | Visual studio | Windows | Xml |
Alarm Clock Specifications
Requirements
The clock displays the time in 24 hour notation. The SET HH button allows changing the hour. The hour will advance with one unit every time the button is pressed. The SET MM button allows the same thing for minutes. The MODE button has 2 modes: Clock and Alarm. If the Clock mode is selected, then the user will set the clock time. If the Alarm mode is set then the time for the alarm to ring will be set with the previously mentioned SET buttons. The Alarm ON/OFF button is used to enable or disable the alarm. if it is disabled then the alarm won't ring when the clock time is equal to the alarm time. The Snooze button allows the pause of the ringing with the resume after a period of time.
Constants
namespace AlarmClock;
the SetTimeMode selects whether the alarm time or the clock time should be set.
enum SetTimeMode
State Variables
SetTimeMode SetMode = SetTimeMode.CLOCK;//default set to CLOCK mode
AlarmEnabled means that the alarm is enabled if it is set to true, otherwise the alarm is disabled. Snoozing set to true means that the Snooze mode is active. Ringing is set to true only when the alarm is ringing.
bool AlarmEnabled = false;//by default the alarm is disabled
bool Snoozing = false;
bool Ringing = false;
int HClock = 0;//the current hour of the clock
int HAlarm = 0;//the currently set hour for the alarm
int MClock = 0;//the current minute of the clock
int MAlarm = 0;//the current minute of the alarm
Actions
SetH method increments the hour for the clock if the mode is set to CLOCK. Otherwise the alarm hour will be incremented. The hour is in the interval 0-23. In the same way the SetM method will increment the minute in the interval 0-59.
//[Action]
//void SetH()
//[Action]
//void SetM()
Next is a state chart that represents the alarm clock transitions and states
The states are practically defined like in the chart above by employing the state variables mentioned in the State Variables section. The actions that are written next in SPEC# are about the same thing with the transitions from the picture above.
The SwitchAlarm method will switch the alarm on or off depending on the current state. When the Snooze method is called the alarm will go into snoozing mode only if it is currently raised and ringing.
[Action]
void SwitchAlarm()
[Action]
void Snooze()
[Action]
void StartRinging()//the clock is quiet and the alarm time arrived
[Action]
void StopRinging()//the ringing period expired and the alarm must go quiet
[Action]
void SnoozeTimeOut()//the clock was is snooze mode and the snooze timed out; the clock needs to go in ringing mode again
//this shows us the current state
string! StopperStatus
;
//if (AlarmEnabled) res += Seq;
if (!AlarmEnabled) res += Seq;
if (AlarmEnabled && !Ringing && !Snoozing) res += Seq;
if (AlarmEnabled && Ringing && !Snoozing) res += Seq;
if (AlarmEnabled && !Ringing && Snoozing) res += Seq;
if(res.Length > 0)
return res[0];
else
return 'Error!';
}
}
void
Politica de confidentialitate | Termeni si conditii de utilizare |
Vizualizari: 757
Importanta:
Termeni si conditii de utilizare | Contact
© SCRIGROUP 2024 . All rights reserved