-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListaSpesa.h
56 lines (33 loc) · 1.13 KB
/
ListaSpesa.h
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
//
// Created by Riccardo Becciolini on 19/02/23.
//
#ifndef PROJECTLAB_LISTASPESA_H
#define PROJECTLAB_LISTASPESA_H
#include <iostream>
#include <list>
#include <algorithm>
#include <iomanip>
#include <memory>
#include "Subject.h"
#include "Prodotto.h"
#include "Observer.h"
class ListaSpesa : public Subject{
public:
explicit ListaSpesa(const std::string& n): name(n){};
void addProd(std::shared_ptr<Prodotto> p, const std::string& u);
int removeProd(std::shared_ptr<Prodotto> p, const std::string& u);
int modifyQuantity(std::shared_ptr<Prodotto> p, int q, const std::string& u);
int buyProd(std::shared_ptr<Prodotto> p, const std::string& u);
void subscribe(Observer* o) override;
void unsubscribe(Observer* o) override;
void notify(int num, const std::string& u) override;
const std::string &getName() const;
void setName(const std::string &name);
int getSize();
const std::list<std::shared_ptr<Prodotto>> &getProducts() const;
private:
std::string name;
std::list<std::shared_ptr<Prodotto>> products;
std::list<Observer*> observers;
};
#endif //PROJECTLAB_LISTASPESA_H