Advertisement
perjespersson

Labb 1

Mar 11th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. #ifndef TIME_H
  2. #define TIME_H
  3.  
  4. #include <string>
  5. #include <sstream>
  6.  
  7. class Time{
  8. public:
  9.     Time();
  10.     Time(int h, int m, int s);
  11.     Time(std::string const& t);
  12.     Time(Time const& other);
  13.     int hour() const noexcept;      //Getter
  14.     int minute() const noexcept;    //Getter
  15.     int second() const noexcept;    //Getter
  16.     void check_boundary(int const h, int const m, int const s) const;
  17.     bool is_am() const;
  18.     std::string to_string() const;
  19.     std::string to_string(bool format) const;
  20.     operator std::string() const;
  21.     bool operator==(Time const& rhs) const;
  22.     bool operator!=(Time const& rhs) const;
  23.     bool operator<(Time const& rhs) const;
  24.     bool operator>(Time const& rhs) const;
  25.     bool operator<=(Time const& rhs) const;
  26.     bool operator>=(Time const& rhs) const;
  27.     Time operator+(int const rhs) const;
  28.     Time operator-(int const rhs) const;
  29.     Time& operator++();
  30.     Time& operator--();
  31.     Time operator++(int);
  32.     Time operator--(int);
  33.  
  34.  
  35. private:
  36.     int h;
  37.     int m;
  38.     int s;
  39. };
  40.  
  41. std::ostream& operator<<(std::ostream& lhs, Time const& rhs);
  42. std::istream& operator>>(std::istream& lhs, Time& rhs);
  43.  
  44. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement