Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AnalogClock {
- public:
- AnalogClock(Time* t) {
- this->t=t;
- }
- float GetAngle() {
- angle = 0;
- int hours = t.GetHours();
- if (hours>12) hours = hours - 12;
- int minutes = t.GetMinutes();
- if (minutes==0) angle = abs(hours*30-minutes*6);
- else angle = abs((hours+1/minutes)*30-minutes*6);
- if (angle>180) angle=abs(180-angle);
- return angle;
- }
- private:
- float angle;
- Time t;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement