Advertisement
add1ctus

Untitled

Mar 19th, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Angle {
  5.     int degrees;
  6.     int minutes;
  7.     int seconds;
  8.    
  9.     public:
  10.     Angle(int a,int b,int c)
  11.     {
  12.         degrees=a;
  13.         minutes=b;
  14.         seconds=c;
  15.     }
  16.    
  17.     void setDegrees(int a)
  18.     {
  19.         degrees=a;
  20.     }
  21.    
  22.     void setMinutes(int a)
  23.     {
  24.         minutes=a;
  25.     }
  26.    
  27.     void setSeconds(int a)
  28.     {
  29.         seconds=a;
  30.     }
  31.     int toSeconds()
  32.     {
  33.         return (degrees*60+minutes)*60+seconds;
  34.     }
  35. };
  36.  
  37. bool check(int a, int b, int c)
  38. {
  39.     if(a>=0&&a<360 && b>=0 && b<60 && c>=0 && c<60)
  40.         return true;
  41.     return false;
  42. }
  43.  
  44. int main() {
  45.    
  46.     Angle a1(1,2,3);
  47.    
  48.     int deg, min, sec;
  49.    
  50.     cin >> deg >> min >> sec;
  51.    
  52.     if (check(deg, min, sec)) {
  53.    
  54.         a1.setDegrees(deg);
  55.         a1.setMinutes(min);
  56.         a1.setSeconds(sec);
  57.         cout << a1.toSeconds();
  58.        
  59.     } else {
  60.         cout << "Invalid values" << endl;
  61.     }
  62.    
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement