/
plat.cpp
109 lines (92 loc) · 1.9 KB
/
plat.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "plat.h"
plat::plat(){}
plat::plat(string _nom, vector<string> _ingredient, int _avis, int _calorie, int _prix, const QString _imagePath){
setNom(_nom);
setIngredient(_ingredient);
setAvis(_avis);
setCalorie(_calorie);
setPrix(_prix);
setImage(_imagePath);
}
plat::~plat(){
delete(image);
}
string plat::getNom() const
{
return nom;
}
void plat::setNom(const string &_nom)
{
nom = _nom;
}
vector<string> plat::getIngredient() const
{
return ingredient;
}
void plat::setIngredient(const vector<string> &_ingredient)
{
ingredient = _ingredient;
}
int plat::getAvis() const
{
return avis;
}
void plat::setAvis(int _avis)
{
if (_avis >= 0 && _avis <= 5)
avis = _avis;
else
ERROR_BAD_VALUE(avis, _avis);
}
int plat::getCalorie() const
{
return calorie;
}
void plat::setCalorie(int _calorie)
{
if (_calorie > 0)
calorie = _calorie;
else
ERROR_BAD_VALUE(calorie, _calorie);
}
int plat::getPrix() const
{
return prix;
}
void plat::setPrix(int _prix)
{
if (prix >= 0)
prix = _prix;
else
ERROR_BAD_VALUE(prix, _prix);
}
QPixmap * plat::getImage() const
{
return image;
}
void plat::setImage(const QString path)
{
if (path.size() > 0)
image = new QPixmap(path);
else
ERROR_BAD_VALUE(image, path.toStdString());
}
string plat::getDescription() const
{
return description;
}
void plat::setDescription(const string &value)
{
description = value;
}
void plat::printAttrib()
{
cout << "Print " << nom << endl << " Ingredients:" << endl;
for(vector<string>::iterator it = ingredient.begin(); it != ingredient.end(); ++it){
cout << " " << *it << endl;
}
cout << " avis " << avis << endl
<< " calorie " << calorie << endl
<< " prix " << prix << endl
<< " description " << description <<endl;
}