-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShoppingBasket.h
38 lines (27 loc) · 999 Bytes
/
ShoppingBasket.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
#ifndef SHOPPINGBASKET_H
#define SHOPPINGBASKET_H
#include <memory>
#include <vector>
#include "Item.h" // Ensure to include the Item header
class ShoppingBasket {
public:
// Constructor
ShoppingBasket(int initialCapacity);
// Destructor
~ShoppingBasket();
// Add an item to the basket
void addItem(std::shared_ptr<Item> item); // Change BaseItem to Item
// Display items in the basket
void displayItems() const;
// Get the current size of the basket
int getSize() const;
// Getter for items (optional, can be used to access items externally)
const std::vector<std::shared_ptr<Item>>& getItems() const;
private:
std::vector<std::shared_ptr<Item>> items; // Vector to hold items
int capacity; // Current capacity of the basket
int size; // Current size of the basket
// Resize the basket when full
void resizeBasket();
};
#endif // SHOPPINGBASKET_H