-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMusicList.h
More file actions
44 lines (34 loc) · 1.2 KB
/
MusicList.h
File metadata and controls
44 lines (34 loc) · 1.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
#ifndef MUSICLIST_H
#define MUSICLIST_H
#include <iostream>
#include <string>
class MusicList {
private:
// Struct representing each node in the linked list
struct MusicNode {
std::string musicTrack; // The music track name
MusicNode* next; // Pointer to the next node in the list
// Constructor to initialize a MusicNode with a track name
MusicNode(const std::string& track)
: musicTrack(track), next(nullptr) {} // Initialize next to nullptr by default
};
MusicNode* head; // Pointer to the first node in the list (head of the linked list)
MusicNode* tail; // Pointer to the last node in the list (tail of the linked list)
int size; // Tracks the number of music tracks (nodes) in the list
public:
// Default constructor
MusicList();
// Add track to the list
void addMusic(const std::string& track);
// Remove the track from the list
std::string removeMusic();
// Check if the list is empty
bool isEmpty() const;
// Method to get the current size of the list
int getSize() const;
// Method to print all tracks in the list
void listAllMusic() const;
// Destructor
~MusicList();
};
#endif