Server IP : 172.16.15.8 / Your IP : 18.188.63.71 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/jcwhiley/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// // #include <iostream> using namespace std; class TimeType { int hrs; int mns; int sec; public: TimeType() { hrs = 8; mns = 0; sec = 0; } TimeType(int h, int m, int s) { hrs = h; mns = m; sec = s; } void Set (int h, int m, int s) { hrs = h; mns = m; sec = s; } void Print() const // observer { cout << hrs << ": " << mns << ": " << sec << "\n"; } void Increment() // transformer { secs ++; } bool Equal(TimeType x) { return hrs == x.hrs && mns == x.mns && sec == x.sec; } }; int main() { // declare an object of time type "present - 2:20" TimeType present(2, 20, 00); // out the present time of the present present.Print(); // "cout << present.hrs is INVALID." // declare an object "anytime" and make it the same as "present" TimeType anytime(0, 0, 0); // or "TimeType anytime;" anytime = present; anytime.Print(); // 8:00:00 cout << "\n..uhh...?\n\n"; // check if anytime == present, if so, out "same time," else out "not." if (anytime.Equal(present)) cout << "Same time.\n"; else cout << "Not. \n"; cout << "\n...What...?\n\n"; return 0; }