Задача: Клас Time
Реалізувати клас Time за наведеною нижче специфікацією.
Увага! Час має нормалізуватися при створенні об'єкта.
Наприклад Time a(8, 75, 210) після створення має мати атрибути Hours = 9, Minutes= 18, Seconds == 30
Зразки виводу:
1) Для Time(1,1,1) — 01:01:01
2) Для Time(23,59,59) — 23:59:59
Увага! Час має нормалізуватися при створенні об'єкта.
Наприклад Time a(8, 75, 210) після створення має мати атрибути Hours = 9, Minutes= 18, Seconds == 30
Зразки виводу:
1) Для Time(1,1,1) — 01:01:01
2) Для Time(23,59,59) — 23:59:59
#include <exception>
#include <iostream>
using namespace std;
class Time
{
public:
struct BadTime;
typedef int Hours;
typedef int Minutes;
typedef int Seconds;
Time (const Hours& h, const Minutes& m, const Seconds& s);
Time (const Seconds &s=0);
Time (const Time&);
~Time(){};
Time& operator=(const Time&);
operator int() const;
const double ToHours() const;
const int ToSeconds() const;
// Selectors
const Hours& getHours() const;
const Minutes& getMinutes() const;
const Seconds& getSeconds() const;
// Modifiers
void setHours(const Hours&);
void setMinutes(const Minutes&);
void setSeconds(const Seconds&);
const Time& operator++();
const Time operator++(int);
const Time& operator--();
const Time operator--(int);
private:
// Mutable attributes in order to allow normalizing in const objects
mutable Hours _hours;
mutable Minutes _minutes;
mutable Seconds _seconds;
void normalizeTime() const;
};
Time& operator+=(Time&, const Time&);
const Time operator+(const Time&, const Time&);
const bool operator==(const Time&, const Time&);
const bool operator!=(const Time&, const Time&);
const bool operator>(const Time&, const Time&);
const bool operator<(const Time&, const Time&);
const bool operator>=(const Time&, const Time&);
const bool operator<=(const Time&, const Time&);
ostream& operator<<(ostream&, const Time&);
struct Time::BadTime
{
Time::Hours _hours;
Time::Minutes _minutes;
Time::Seconds _seconds;
};
- 0
- 01 червня 2013, 14:45
- GarfieldUA
- Залишити коментар
Розробка класів на основі стратегій
Дана доповідь присвячена розробці класів на основі стратегій. Основна увага в презентації присвячена сутності поняття стратегія, а також призначенню стратегій. Протягом лекції буде розказано і про причини необхідності застосування стратегій. Крім того багато уваги присвячено питанню побудови правильних стратегій і головних класів, а також зв'язкам між стратегіями. Під кінець піднімається питання ортогональної декомпозиції.
Презентація
Реалізація
Доповідач: Герич З.О.
Презентація
Реалізація
Доповідач: Герич З.О.
- 0
- 25 квітня 2013, 21:59
- GarfieldUA
- Залишити коментар