From 88f15e35713c9632216931d26443dc588238732f Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 7 May 2024 22:17:12 +0300 Subject: [w10] Added rough solutions to ex 1-10 --- week10/Exercise04/Time12.cpp | 10 ++++++++++ week10/Exercise04/Time12.h | 9 +++++++++ week10/Exercise04/Time24.cpp | 11 +++++++++++ week10/Exercise04/Time24.h | 11 +++++++++++ 4 files changed, 41 insertions(+) create mode 100644 week10/Exercise04/Time12.cpp create mode 100644 week10/Exercise04/Time12.h create mode 100644 week10/Exercise04/Time24.cpp create mode 100644 week10/Exercise04/Time24.h (limited to 'week10/Exercise04') 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 + +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 + +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(); +}; -- cgit v1.2.3