I have become one tipp of the teacher ,which might would help to implement the Switch off Method :
For each object that represents an entry (copy of the cash register
"CLogEntry") there is a method with the off time in the
Entry can be set ("switchedOffAt"). The method is
described in detail:
/ **
* Sets the switch-off time of the dimmer and thus the
* Duty cycle fixed.
*
* offTime: the off time as seconds since midnight.
* If the value is less than the switch-on time, will
* assumed that the dimmer closest
* Day was turned off (for example, means one
* On time 22:00:00 off at 01:00:00
* that the dimmer was switched on for 3 hours).
* /
void switchedOffAt (unsigned int offTime);
*/
void switchedOff();
That the switch-off time is not a value transferred in the parameter
used but the current time. The method could as well
"switchedOffNow ()", but that would in my opinion the
Make designation unnecessarily long. The method saves the user
the class "CLogEntry" to first have to determine the current time
and then call "switchedOffAt" with this determined time.
The implementation of "switchedOff ()" is obvious: you
call "switchedOffAt" with the current time as an argument
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
void CDimmerLogEntry::switchedOff()
{
CTimeofDay();
CDimmerLogEntry::switchedoffAt();
}
Bei der 2 Methode :
void CDimmerLogEntry::switchedOffAt(unsigned int offTime)
{
if(m_startTime < offTime){
m_duration = offTime- m_startTime;
m_duration = m_duration/24;
}
if(m_startTime >offTime){
m_duration = -1*(-offTime +m_startTime)+3600;
m_duration = m_duration/24;
}
Of(m_startTime == offTime){
cout << m_startTime << endl;
}
| |
Is this right?