practice in class ( i dont know how to implement the add time and tick seconds functions) plz need assistance asap

#include <iostream>
#include <cstdlib>
using namespace std;

class Time
{
private:
int hour, minute, second;

public:
Time addTime(Time);
void tickSecond();
void setTime(int, int, int);
void setHours(int);
Time getTime();
bool runningBehind(Time);
void printMilitaryTime();
void printTime();


};

Time Time::addTime(Time t)
{

}

void Time::tickSecond()
{

}

void Time::setTime(int h, int m, int s)
{
hour = h;
minute = m;
second = s;
}

void Time::setHours(int)
{

}

Time Time::getTime()
{

}

bool Time::runningBehind(Time t)
{
)
}

void Time::printMilitaryTime()
{

}

void Time::printTime()
{

}


int main()
{
time t1, t2, t3;
char runAgain;

do{
t1.setTime(23,59,59);
t2.setTime(rand()%24, rand()%60, rand()%60);
t3.setTime(rand()%24, rand()%60, rand()%60);

cout<<"t1 is:"; t1.printTime(); cout<<endl;
cout<<"t2 is:"; t2.printTime(); cout<<endl;
cout<<"t3 is:"; t3.printTime(); cout<<endl;

if(t2.runningBehind(t3))
{
t2.printTime();
cout << " is running behind ";
t3.printTime();
cout<<endl;
}
else
{
t3.printMilitaryTime();
cout << " is running behind ";
t2.printMilitaryTime();
cout<<endl;
}

t3 = t1.addTime(t2); cout<<"New added time:"; t3.printTime(); cout<<endl;
t1.tickSeconds(); cout<<"T1 after being ticked:"; t1.printTime(); cout<<endl;
t2.tickSeconds(); cout<<"T2 after being ticked:"; t2.printTime(); cout<<endl;

cout<<endl<<"Do you want to run again (y/n): ";
cin >> runAgain;
cout<<endl;
}while (runAgain=='y' || runAgain=='Y');

return 0;
}
Last edited on
Topic archived. No new replies allowed.