GRP7.2


 * GRP 7**

NAME: Sia Han Yung NAME: Li Jia Le

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

class PT{ protected: int x, y, z; public: PT{x=0; y=0; z=0;}; PT(int x1, int y1, int z1){x = x1; y = y1; z = z1;}; ~PT{};

PT NEGATE(PT neg){ neg.y = 0-y1; neg.z = 0-z1; neg.x = 0-x1; return neg; };

PT NORM(PT norm){ norm.dist = sqrt((z-0)^2+(x-0)^2+(y-0)^2); return norm; };

PT PRINT(PT print){ cout << "(" << x << "," << y << "," << z << ")" << endl; }; code //Task 3 - TIME// Li Jia Le //3O3// 17 // 28/07/2010 using namespace std;
 * 1) include
 * 2) include 
 * 3) include 
 * 4) include 

class TIME{

protected: int h, m, s;

public: TIME{h = 00; m = 00; s = 00;}; void Set_h(int h1){h = h1;}; void Set_m(int m1){m = m1;}; void Set_s(int s1){s = s1;}; ~TIME{};

void DISPLAY{

cout << h << ":" << m << ":" << s << endl; };

TIME RESET{ h=00; m=00; s=00; } TIME ADVANCE(int hh, int mm, int ss){ s=s+ss; if (s>59) {m=m+1; s=(s+ss)-60;}; m=m+mm; if (m>59) {h=h+1; m=(m+mm)-60;}; h=h+hh; if (h>23) {h=h-24;}; } };

int main(void){ int inh, inm, ins;

TIME tt;

time_t now; time(&now);

cout << endl; cout << "Current time is: " << ctime(&now) << endl; cout << endl;

cout << "Please re-enter your current time in the following format >> hh mm ss" << endl; cin>>inh>>inm>>ins; tt.Set_h(inh); tt.Set_m(inm); tt.Set_s(ins); cout << "Enter the value of advancement : "<< endl; cin >> inh >> inm >> ins;

tt.ADVANCE(inh, inm, ins); cout << "Your advanced time is: ";

tt.DISPLAY; cout << "Time Reset: " << endl;

tt.RESET;

tt.DISPLAY;

system("pause"); return EXIT_SUCCESS; } ||

Sia Han Yung Mission 2B Submission - TIME CLASS

code format="cpp" using namespace std; ////////////////////////////////////////////////////////////// class TIME{ protected: int hour, min, sec;
 * 1) include
 * 2) include 

public: TIME{hour=0; min=0; sec=0;}; TIME (int h, int m, int s){hour=h; min=m; sec=s;}; ~TIME{};

void Set_hour(int h){hour=h;}; void Set_min(int m){min=m;}; void Set_sec(int s){sec=s;};

TIME Display{ cout<59) { min=min+1; sec=sec-60; };

min=min+m1; while (min>59) { hour=hour+1; min=min-60; };

hour=hour+h1; while (hour>23) { hour=hour-24; } } }; ////////////////////////////////////////////////////////////// int main{ int hour1, min1, sec1;

TIME input;

time_t now; time(&now); cout << "Current time +8GMT is: " << ctime(&now) << endl;

cout << "Please re-enter the +8GMT time:" ; cin>>hour1>>min1>>sec1; input.Set_hour(hour1); input.Set_min(min1); input.Set_sec(sec1); cout << "Enter the advancement of time of intended destination: "; cin >> hour1 >> min1 >> sec1; input.ADVANCE(hour1, min1, sec1); cout << "The time at your destination is: "; input.Display; cout << endl;

cout << "Time Reset: ";

input.RESET;

input.Display;

system("pause"); return 0; } ///////////////////////////////////////////////////////// code