You are on page 1of 3

// Date // KUEU2133

: 2012.05.16 : Computer and programming

// Assignment : Object oriented // Group members // 1. Alimin Jaman Ali // 2. Muhammad Faiz Bin Zulkeflee KEU100023 // 3. Muhd Firdaus Abdul Suhaimi KEU100024 #include<iostream.h> class time { public: time(); void set_time (int, int, int); void get_time_ori(); void get_time_new(); private: int hour; int minute; int second; }; time::time() // function initially set to time(0,0,0) { hour=0; minute=0; second=0; } void time::set_time(int H, int M, int S) // function to set the time(H,M,S) { hour=H; minute=M; second=S; } KEU100003

void time::get_time_ori() // function to call back the origirnal time { cout<<"Hour: 10\n"; cout<<"Minute: 5\n"; cout<<"Second: 5\n"; } void time::get_time_new() // function to call back a new data with new time(H,M,S) { cout<<hour<<":"<<minute<<":"<<second; } int main() { time t; cout<<"Create an object called time (10,5,5)\n"; cout<<"Display the values of the Time data members using get functions:\n"; t.get_time_ori(); // call back function time, struck time_ori. cout<<"\nOriginal Time:\n10:5:5"; cout<<"\nModify the time to 12:12:12 using set functions:\n"; t.set_time(12,12,12); // set function time (int H, int M, int S) --> time(12,12,12) cout<<"\nNew Time:\n"; t.get_time_new(); // call back function time, struck time_new. cout<<"\n"; return 0; }

You might also like