diff options
Diffstat (limited to 'week10/Exercise04')
| -rw-r--r-- | week10/Exercise04/Time12.cpp | 10 | ||||
| -rw-r--r-- | week10/Exercise04/Time12.h | 9 | ||||
| -rw-r--r-- | week10/Exercise04/Time24.cpp | 11 | ||||
| -rw-r--r-- | week10/Exercise04/Time24.h | 11 |
4 files changed, 41 insertions, 0 deletions
diff --git a/week10/Exercise04/Time12.cpp b/week10/Exercise04/Time12.cpp new file mode 100644 index 0000000..3d1d681 --- /dev/null +++ b/week10/Exercise04/Time12.cpp @@ -0,0 +1,10 @@ +#include "Time12.h" +#include <iostream> + +Time12::Time12(unsigned hours, unsigned minutes, bool pm) : Time24(hours, minutes) { + this->pm = pm; +} + +void Time12::Print12() { + std::cout << hours << ":" << minutes << " " << (pm ? "PM" : "AM"); +} diff --git a/week10/Exercise04/Time12.h b/week10/Exercise04/Time12.h new file mode 100644 index 0000000..24669e6 --- /dev/null +++ b/week10/Exercise04/Time12.h @@ -0,0 +1,9 @@ +#pragma once +#include "Time24.h" + +class Time12 : Time24 { + bool pm; +public: + Time12(unsigned hours, unsigned minutes, bool pm); + void Print12(); +}; diff --git a/week10/Exercise04/Time24.cpp b/week10/Exercise04/Time24.cpp new file mode 100644 index 0000000..59f4680 --- /dev/null +++ b/week10/Exercise04/Time24.cpp @@ -0,0 +1,11 @@ +#include "Time24.h" +#include <iostream> + +void Time24::Print24() { + std::cout << hours << ":" << minutes; +} + +Time24::Time24(unsigned hours, unsigned minutes) { + this->hours = hours; + this->minutes = minutes; +} diff --git a/week10/Exercise04/Time24.h b/week10/Exercise04/Time24.h new file mode 100644 index 0000000..9b5d598 --- /dev/null +++ b/week10/Exercise04/Time24.h @@ -0,0 +1,11 @@ +#pragma once + +class Time24 { +protected: + unsigned hours; + unsigned minutes; + +public: + Time24(unsigned hours, unsigned minutes); + void Print24(); +}; |
