-
Notifications
You must be signed in to change notification settings - Fork 0
/
wishlist_Repo.cpp
63 lines (55 loc) · 1.6 KB
/
wishlist_Repo.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
#include "wishlist_Repo.h"
void wish_list::goleste_cos() noexcept {
this->Lista.clear();
}
void wish_list::add(Oferta x)
{
this->Lista.push_back(x);
}
void wish_list::genereaza(int x, vector<Oferta> v)
{
/// generam x oferte
this->goleste_cos();
shuffle(v.begin(), v.end(), default_random_engine(time(0)));
for (int i = 0; i < x && !v.empty(); i++)
{
this->add(v.back());
v.pop_back();
}
}
vector<Oferta> wish_list::getList()
{
return this->Lista;
}
void wish_list::Export(string nume_fisier)
{
ofstream fout(nume_fisier);
if (nume_fisier.at(0) % 2)
{
fout << "<html>";
fout << "<style> p {text-align: center;} body{background-color: #E6E6FA;} </style>";
fout << "<body>";
fout << "<big><big><p><big><b>id denumire destinatie tip pret</b></big><br>";
for (auto& x : this->Lista)
{
fout << x.id << " " << x.denumire << " " << x.destinatie
<< " " << x.tip << " " << x.pret << "<br>";
}
fout << "</p></big></big></body>";
fout << "<html>";
}
else
{
fout << "<html>";
fout << "<style> table, th, td {border:1px solid black} body{background-color: #E6E6FA;} </style>";
fout << "<body>";
fout << "<table><tr><th>id</th> <th>denumire</th> <th>destinatie</th> <th>tip </th><th>pret</th></tr>";
for (auto& x : this->Lista)
{
fout << "<tr><td>" << x.id << "<td>" << x.denumire << "</td><td>" << x.destinatie
<< "</td><td>" << x.tip << "</td><td>" << x.pret << "</td></tr>";
}
fout << "</table></body>";
fout << "<html>";
}
}