-
Notifications
You must be signed in to change notification settings - Fork 0
/
Product.cpp
64 lines (58 loc) · 1.27 KB
/
Product.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
#include "Product.h"
ostream& operator<<(ostream& out, const Category category)
{
switch (category)
{
case Category::none: out << "None"; break;
case Category::smartphones: out << "Smartphones"; break;
case Category::shoes: out << "Shoes"; break;
case Category::notebooks: out << "Notebooks"; break;
}
return out;
}
Product::Product()
{
this->name = "";
this->price = 0;
this->category = Category::none;
this->id = 0;
}
Product::Product(string name, double price, Category category, int id)
{
this->name = name;
this->price = price;
this->category = category;
this->id = id;
}
bool operator==(Product first, Product second)
{
if (first.getName() == second.getName() && first.getPrice() == second.getPrice()
&& first.getCategory() == second.getCategory() && first.getId() == second.getId())
{
return true;
}
return false;
}
string Product::getName() const
{
return this->name;
}
double Product::getPrice() const
{
return this->price;
}
const Category& Product::getCategory() const
{
return this->category;
}
int Product::getId() const
{
return this->id;
}
void Product::print() const
{
cout << "Name: " << this->name << endl;
cout << "Category: " << this->category << endl;
cout << "Price: " << this->price << endl;
cout << "ID: " << this->id << endl << endl;
}