Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Instructions Now add the following three methods to your Time class: void getHou

ID: 3822499 • Letter: I

Question

Instructions

Now add the following three methods to your Time class:

void getHourCoords ( float& x, float& y )

void getMinuteCoords ( float& x, float& y )

void getsecondsCoords ( float& x, float& y )

Each method should return the point of intersection of its respective hand with the unit circle. The point can be easily computed from the angles you were asked to derive in the previous question.

Your code will be tested with the timeCoords.cpp

Time.h

#ifndef _mytime2_H_
#define _mytime2_H_

#include <ctime>

class Time
{
int h;
int m;
int s;

public:
Time()
{
std::time_t t = std::time(NULL);
std::tm* tm = std::localtime ( &t ); // returns pointer to a static object
h = tm->tm_hour;
m = tm->tm_min;
s = tm->tm_sec;
}

Time(int h, int m, int s)
: h(h), m(m), s(s)
{
}

int getHours()
{
return h;
}

int getMinutes()
{
return m;
}

int getSeconds()
{
return s;
}

void add(const Time& t)
{
// seconds
int rs = s + t.s;
s = rs % 60;

// minutes
int rm = m + t.m + (rs/60);
m = rm % 60;

// hours
int rh = h + t.h + (rm/60);
h = rh % 24;
}
};

#endif

test code do not changing

timecoord.cpp

sample result

hrs: (0.595, -0.804)
min: (-0.978, 0.208)
sec: (0.951, 0.309)

Explanation / Answer

void getHourCoords ( float& x, float& y )
   {
     int degrees=0;
     if(h>0 && h<=12)
     {
      degrees= h*30;
      x=cos((3.14*degrees)/180);
      y=sin((3.14*degrees)/180);
      
  }

  
  
   }
  
void getMinuteCoords ( float& x, float& y )
{
  int degrees=0;
     if(h>0 && h<=60)
     {
      degrees= h*6;
      x=cos((3.14*degrees)/180);
      y=sin((3.14*degrees)/180);
      
  }
}

void getsecondsCoords ( float& x, float& y )
{
  int degrees=0;
     if(h>0 && h<=60)
     {
      degrees= h*6;
      x=cos((3.14*degrees)/180);
      y=sin((3.14*degrees)/180);
      
  }
}