-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRepo.cpp
64 lines (55 loc) · 1.15 KB
/
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
64
#include "Repo.h"
Repo::Repo(string fisier1)
{
// constructor
fisier = fisier1;
ifstream f(fisier);
string a, b, c, d, e;
while (f >> a >> b >> c >> d >> e)
{
int an = stoi(c);
double pret = stod(e);
device x(a, b, an, d, pret);
lista_device.push_back(x);
}
}
vector<device> Repo::getList()
{
// returnam lista de device-uri
return this->lista_device;
}
string Repo::cauta(string text)
{
// cautam un text dat
for (int i = 0; i < lista_device.size(); i++)
{
string aux = lista_device[i].model + " " + lista_device[i].culoare + " " + to_string(lista_device[i].pret);
if (text == aux)
{
return lista_device[i].model + " " + to_string(lista_device[i].an);
}
}
return "error";
}
vector<device> Repo::filtrare_model(string model)
{
// filtram dupa un model dat
vector<device> v;
for (int i = 0; i < lista_device.size(); i++)
{
if (lista_device[i].model == model)
v.push_back(lista_device[i]);
}
return v;
}
vector<device> Repo::filtrare_an(int an)
{
// filtram dupa un an dat
vector<device> v;
for (int i = 0; i < lista_device.size(); i++)
{
if (lista_device[i].an == an)
v.push_back(lista_device[i]);
}
return v;
}