ifndef Receipt_h__ define Receipt_h__ include string include Date Стру

 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
77
78
79
80
81
82
83
84
#ifndef Receipt_h__
#define Receipt_h__
#include <string>
#include "Date.h"
// Структура для Ф.И.О
struct FIO
{
FIO() {}
FIO(char *n, char* s, char *p)
: name(n), surname(s), patronyc(p)
{}
std::string name;
std::string surname;
std::string patronyc;
std::string toString()
{
return surname + " " + name + " " + patronyc;
}
};
// Структура квитанции
struct Receipt
{
Receipt(unsigned int id, const FIO &fio, double price, unsigned floor,
const Date &checkIn, const Date &checkOut, bool hasConditioner, bool hasPhone,
bool hasRefrigerator, bool hasTVBlackWhite, bool hasTVColor)
{
this->id = id;
this->fio = fio;
this->price = price;
this->floor = floor;
this->checkIn = checkIn;
this->checkOut = checkOut;
this->hasConditioner = hasConditioner;
this->hasPhone = hasPhone;
this->hasRefrigerator = hasRefrigerator;
this->hasTVBlackWhite = hasTVBlackWhite;
this->hasTVColor = hasTVColor;
}
unsigned int id;
FIO fio;
double price;
unsigned floor;
Date checkIn;
Date checkOut;
bool hasPhone;
bool hasRefrigerator;
bool hasConditioner;
bool hasTVColor;
bool hasTVBlackWhite;
int residence()
{
return getDifferenceInDays(checkOut, checkIn);
}
double totalCost()
{
int res = residence();
double totalPrice = price;
if (floor == 1 || floor == 12)
totalPrice = totalPrice * 0.9;
double total = res * totalPrice;
double result = total;
if (hasPhone) result += total * 0.02;
if (hasConditioner) result += total * 0.05;
if (hasRefrigerator) result += total * 0.02;
if (hasTVBlackWhite) result += total * 0.01;
if (hasTVColor) result += total * 0.03;
return result;
}
};
#endif // Receipt_h__