Advertisement
serikov

Untitled

Jun 23rd, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. class AnalogClock {
  2.    public:
  3.       AnalogClock(Time* t) {    // передаем указатель на экземпляр класса время
  4.       atime = t;
  5.       }
  6.  
  7.       float GetAngle() {
  8.          angle = 0;
  9.          int hours = atime->GetHours();
  10.          if (hours>12) hours = hours - 12;
  11.          int minutes = atime->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 atime;
  21. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement