Advertisement
serikov

Untitled

Jun 23rd, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. class AnalogClock {
  2.    public:
  3.       AnalogClock(Time* t) {
  4.       this->t=t;
  5.       }
  6.  
  7.       float GetAngle() {
  8.          angle = 0;
  9.              int hours = t.GetHours();
  10.          if (hours>12) hours = hours - 12;
  11.          int minutes = t.GetMinutes();
  12.          if (minutes==0) angle = abs(hours*30-minutes*6);
  13.          else angle = abs((hours+1/minutes)*30-minutes*6);
  14.          if (angle>180) angle=abs(180-angle);
  15.          return angle;
  16.         }
  17.  
  18.     private:
  19.         float angle;
  20.         Time t;
  21. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement