FMI Ticket System
| Kamen Mladenov | FMI Computer Science Year 1 Group 6 | Project 1 | Project Topic 4 |
Date.h
Go to the documentation of this file.
1#ifndef HEADER_DATE
2#define HEADER_DATE
3
8#include <istream>
9#include <ostream>
10#include "../String/String.h"
11
14class Date {
15 unsigned short day;
16 unsigned short month;
17 unsigned short year;
18
19 bool isLeapYear();
20 unsigned short daysInMonth();
21
22public:
24 Date();
26 Date(const char* str);
28 Date(unsigned short day, unsigned short month, unsigned short year);
29
31 unsigned short get_day() const;
33 bool set_day(unsigned short day);
35 unsigned short get_month() const;
37 bool set_month(unsigned short month);
39 unsigned short get_year() const;
41 bool set_year(unsigned short year);
42
44 String createString() const;
45
47 void read(std::istream& istr);
49 void write(std::ostream& ostr);
51 int compare(const Date& other) const;
52};
53
55std::istream& operator>>(std::istream& istr, Date& dt);
57std::ostream& operator<<(std::ostream& ostr, const Date& dt);
58
59#endif
std::ostream & operator<<(std::ostream &ostr, const Date &dt)
Writes date to stream with << operator.
Definition: Date.cpp:171
std::istream & operator>>(std::istream &istr, Date &dt)
Reads date from stream with >> operator.
Definition: Date.cpp:159
Stores a day, month and year.
Definition: Date.h:14
unsigned short get_year() const
Returns the year.
Definition: Date.cpp:87
unsigned short get_day() const
Returns the day.
Definition: Date.cpp:57
int compare(const Date &other) const
Compares two dates.
Definition: Date.cpp:145
Date()
Sets date as 01 May 2022.
Definition: Date.cpp:21
bool set_year(unsigned short year)
Sets the year.
Definition: Date.cpp:95
String createString() const
Returns the date as a String object.
Definition: Date.cpp:112
unsigned short get_month() const
Returns the month.
Definition: Date.cpp:72
void read(std::istream &istr)
Reads date from stream.
Definition: Date.cpp:124
void write(std::ostream &ostr)
Writes date to stream.
Definition: Date.cpp:137
bool set_day(unsigned short day)
Sets the day.
Definition: Date.cpp:65
bool set_month(unsigned short month)
Sets the month.
Definition: Date.cpp:80
Definition: String.h:11