-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShoppingCart.h
More file actions
38 lines (29 loc) · 897 Bytes
/
ShoppingCart.h
File metadata and controls
38 lines (29 loc) · 897 Bytes
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
// Tyeon Ford
#ifndef SHOPPINGCART_H
#define SHOPPINGCART_H
#include "Product.h"
#include <vector>
#include <map>
using namespace std;
// friendsss
class ReceiptPrinter;
class ShoppingCart {
private:
map<Product*, int> items; // Product pointer -> quantity
public:
ShoppingCart();
~ShoppingCart() = default;
// Cart operations
bool addItem(Product* product, int quantity);
bool removeItem(Product* product, int quantity);
bool isEmpty() const;
void clearCart();
double getTotal() const;
// Friend function declaration
friend void printReceipt(const ShoppingCart& cart);
// Getter for items (for checkout)
const map<Product*, int>& getItems() const;
};
// Friend function - can access private members of ShoppingCart
void printReceipt(const ShoppingCart& cart);
#endif