GRP3.2


 * GRP 3**

NAME: Wong Jun Ming 3S2 (29) NAME: Tan Yu Zhi 3S2 (27)


 * Point Class**

code format="cpp-qt" /* Point Class OO Programming Done by: Wong Jun Ming 3S2 (29) Tan Yu Zhi 3S2 (27)

using namespace std;
 * 1) include
 * 2) include 

class PT { protected: int X, Y, Z;   public: PT{X=0; Y=0; Z=0;}; // Default Constructor PT(int XX, int YY, int ZZ){X=XX; Y=YY; Z=ZZ;}; // Constructor ~PT{}; // Destructor

// Functions void PRINT{ cout<<"("<

class TIME { protected: int H, M, S;       void fixTime { if (S>=60) { M+=S/60; S%=60; }           if (M>=60) { H+=M/60; M%=60; }           if (H>24) H%=24; }   public: TIME{H=12; M=0; S=0;fixTime;}; // Default Constructor TIME(int HH, int MM, int SS){H=HH; M=MM; S=SS;fixTime;}; // Constructor ~TIME{}; // Destructor // Functions void Display{ if (H<10) cout<<"0"<<H<<":"; else cout<<H<<":"; if (M<10) cout<<"0"<<M<<":"; else cout<<M<<":"; if (S<10) cout<<"0"<<S; else cout<<S; };       void Advance(int h, int m, int s){ H+=h; M+=m; S+=s; fixTime; };       void Reset(int h, int m, int s){ H=h; M=m; S=s; fixTime; }; };

int main { TIME time1; time1.Reset(3,55,55); time1.Display; cout<=60){ min=min+(sec/60); sec=sec%60; }                     if (min>=60){ hour=hour+(min/60); min=min%60; }                     if (hour>=24){ hour=hour%24; }

}

public: Time{hour=12; min=0; sec=0;}; //Default Constructor Time(int h, int m, int s){hour=h; min=m; sec=s; tunetime;}; //Constructor ~Time{}; //Destructor

void Display{ if (hour>10)cout<10) cout<10) cout<<sec; else cout<< "0"<<sec; cout<< endl; }; //Display

Time Advance(int hour2, int min2, int sec2){ hour=hour+hour2; min=min+min2; sec=sec+sec2; tunetime; }// Advance time Time Reset(int hour2, int min2, int sec2){ hour=hour2; min=min2; sec=sec2; tunetime; }// Reset time

}; // Time Class

int main{ Time t1(8,35,45); t1.Reset(3,35,3); //Reset the default time value t1.Display;

t1.Advance(21,25,57); // Advance time t1.Display;

system ("pause"); return 0; }

code