Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AnalogClock {
- public:
- AnalogClock(Time* t) { // передаем указатель на экземпляр класса время
- atime = t;
- }
- float GetAngle() {
- angle = 0;
- int hours = atime->GetHours();
- if (hours>12) hours = hours - 12;
- int minutes = atime->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 atime;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement