-
Notifications
You must be signed in to change notification settings - Fork 0
/
sale.cpp
67 lines (60 loc) · 1.67 KB
/
sale.cpp
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
#include <string>
#include <iostream>
#include "sale.hpp"
using namespace std;
// -- Constructor --
sale::sale(string vn,string n,date d){
vrn = vn;
rn = n;
saledate = d;
}
// -- Modify functions --
void sale::changeowner(string _rn) { rn = _rn; }
void sale::changevehicle(string _vrn) { vrn = _vrn; }
// -- Auxiliary functions --
string sale::rvrn() { return vrn; }
string sale::rorn() { return rn; }
bool sale::greaterequalthan(date date) {
if (saledate.year > date.year) {
return 1;
}
else if ((saledate.month > date.month) && (saledate.year == date.year)) {
return 1;
}
else if ((saledate.day > date.day) && (saledate.month == date.month) && (saledate.year == date.year)) {
return 1;
}
else {
return 0;
}
}
bool sale::equalthan(date date) {
if ((date.day == saledate.day) && (date.month == saledate.month) && (date.year == saledate.year)) {
return 1;
}
else return 0;
}
// -- Show functions --
void sale::showsale() { // Vehicle information, Owner information, Date of sale DD/MM/YYYY
cout << "Vehicle sold: " << vrn << " Owner: " << rn << " Date of sale: " << saledate.day << "/" << saledate.month << "/" << saledate.year << endl;
}
// -- Formatting functions --
string sale::reg() { // Returns string of formatted parameters
string temp, space = " ", day = to_string(saledate.day), month = to_string(saledate.month), year = to_string(saledate.year);
temp = vrn;
temp += space;
temp += rn;
temp += space;
temp += day;
temp += space;
temp += month;
temp += space;
temp += year;
temp += space;
return temp;
}
string sale::to_string(int a){
stringstream stream;
stream << a;
return stream.str();
}