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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
#include <iostream>
#include <iomanip>
using std::cout;
using std::setfill;
using std::setw;
using std::cin;
using std::cout;
using std::endl;
class Time
{
private:
int hour;
int minute;
int second;
int amount;
public:
Time( int = 0, int = 0, int = 0 );
const Time Time::operator+(const Time &other) ;
void setTime( int, int, int );
void setHour( int );
void setMinute( int );
void setSecond( int );
int getHour() const;
int getMinute() const;
int getSecond() const;
void Time::get( );
void Time::show();
void change( int amount, int &hours, int &minute, int &seconds);
};
Time::Time( int hour, int minute, int second )
{
setTime( hour, minute, second );
}
void Time::setTime( int hour, int minute, int second )
{
setHour( hour );
setMinute( minute );
setSecond( second );
}
void Time::get( )
{
int amount;
cout << "Enter the amount: " << endl;
cin >> amount;
}
void Time::setHour( int h )
{
hour = h;
}
void Time::setMinute( int m )
{
minute = m;
}
void Time::setSecond( int s )
{
second = s;
}
int Time::getHour ( ) const
{
return hour;
}
int Time::getMinute () const
{
return minute;
}
int Time::getSecond () const
{
return second;
}
void change(int amount, int &hours, int &minute, int &seconds)
{
hours = amount/60;
amount %=60;
minute = amount/60;
amount %=60;
seconds = amount/120;
}
void Time::show ()
{
std::cout <<"Hours"<<hour<<"Minutes"<<minute<<"Seconds"<<second<<endl;
}
int main()
{
Time time1, time2, time3;
time1.get();
time2.get();
time3.show();
system("pause");
return 0;
}
|