1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
#include <string>
#include <cstdlib>
#include "unsorted.h"
#include "Appointment.h"
#include <iomanip>
#include <vector>
using namespace std;
Appointment::Appointment()
{
day = 0;
month = 0;
year = 0;
desc = "";
}
Appointment::Appointment(int num, int num1, int num2, string a)
{
day = num;
month = num1;
year = num2;
desc = a;
}
istream& operator >> (istream& ins, Appointment& arg)
{
Appointment temp;
string s, x, y;
label1:
getline(cin, s);
if (arg.getChecker() == s)
{
cout << "Error! Appointment has already been entered.";
cout << "Add the date and description of your appointment:";
goto label1;
}
int index = s.find(" ");
x = s.substr(0, index);
y = s.substr(index, s.length());
arg.desc = y;
if (x.length() == 9)
{
arg.day = stoi(x.substr(2, 2).c_str());
arg.month = stoi(x.substr(0, 1).c_str());
arg.year = stoi(x.substr(5, 4).c_str());
}
else
{
arg.day = stoi(x.substr(3, 2).c_str());
arg.month = stoi(x.substr(0, 2).c_str());
arg.year = stoi(x.substr(6, 4).c_str());
}
arg.length = arg.getLength() + 1;
arg.checker = s;
cin.clear();
return ins;
}
ostream& operator << (ostream& out, const Appointment& arg)
{
out << arg.getDay() << "/" << arg.getMonth() << "/" << arg.getYear() << " " << arg.getDesc();
return out;
}
|