clock type
Jul 13, 2011 at 7:48pm UTC
1 2 3 4 5 6
bool clockType:: isEarlier (clockType otherClock)
{
return (hr>otherClock.hr &&
min>otherClock.min
&& sec==otherClock.sec);
}
this method returns true if the time in this clockType object is earlier than the time in clockType obect otherClock. otherwise is returns false
i dont want to post all the code in here is long but if i have to i will this is the only thing that is wrong
heres more of the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
//added methods
void addSeconds(int n);
void addMinutes(int n);
void addHours(int n);
bool isEarlier(const clockType & otherClock)const ;
private :
int hr;
int min;
int sec;
};
void clockType:: addSeconds (int m)
{
int sum=m+sec;
if (sum<60)
{
sec=0;//make seconds equal to zero
min++;
}
}
void clockType:: addMinutes(int m)
{
int sum=m+min;
if (sum<60)
{
min=0;
hr++;
}
}
void clockType :: addHours (int m)
{
int sum=m+hr;
if (sum>24)
{
hr=0;
}
}
bool clockType:: equalTime(const clockType& otherClock) const
{
return (hr== otherClock.hr &&
min==otherClock.min
&& sec ==otherClock.sec);
}
bool clockType:: isEarlier (clockType otherClock)
{
if ( clockType>otherClock)
return true ;
}
Last edited on Jul 13, 2011 at 7:52pm UTC
Jul 13, 2011 at 8:06pm UTC
I don't see a question or description of a problem. What do you want?
Jul 13, 2011 at 8:08pm UTC
the bool is Earlier is not working and i change it up many times
this is why i try it againg differently
1 2 3 4 5 6 7
bool clockType:: isEarlier (clockType otherClock)
{
int diff = hr - otherClock.hr;
if (diff == 0) diff = min - otherClock.min;
if (diff == 0) diff = sec - otherClock.sec;
return diff > 0;
}
thanks
Topic archived. No new replies allowed.