-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItemList.h
More file actions
75 lines (57 loc) · 2.2 KB
/
ItemList.h
File metadata and controls
75 lines (57 loc) · 2.2 KB
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
65
66
67
68
69
70
71
72
73
74
75
#ifndef ITEMLIST_H
#define ITEMLIST_H
#include <string>
#include <iostream>
class ItemList {
private:
// Struct representing each node in the doubly linked list
struct ItemNode {
std::string itemName; // Name of the item
int itemCost; // Name of the item
ItemNode* next; // Pointer to the next node in the list
ItemNode* prev; // Pointer to the previous node in the list
// Constructor to initialize the node with item name and cost
ItemNode(const std::string& name, int cost)
: itemName(name), itemCost(cost), next(nullptr), prev(nullptr) {}
};
ItemNode* head; // Pointer to the first node in the list
ItemNode* tail; // Pointer to the last node in the list
int size; // Number of items in the list
ItemNode* current; // Pointer to track the current item
bool isItemActivated = false; // Boolean flag to track whether an item is activated
public:
// Default constructor
ItemList();
// Add a new item to the list with a name and cost
void addItem(const std::string& name, int cost);
// Remove an item from the list by its name
void removeItem(const std::string& itemName);
// Check if the list is empty
bool isEmpty() const;
// Get the current size of the list
int getSize() const;
// Print all items in the list
void listAllItems() const;
// Check if a particular item exists in the list
bool findItem(const std::string& itemName) const;
// Display the details of the current item
void getCurrentItem() const;
// Move the current pointer to the previous item in the list
void moveLeft();
// Move the current pointer to the next item in the list
void moveRight();
// Getter & Setter for item activation status
bool getIsItemActivated() const;
void setIsItemActivated(bool status);
// Function to activate the current item
void activateItem();
// Prompt the user to activate the current item
void promptActivateItem();
// Remove the current item from the list
void removeCurrentItem();
// Prompt the user to remove the current item
void promptRemoveCurrentItem();
// Destructor
~ItemList();
};
#endif