-
Notifications
You must be signed in to change notification settings - Fork 0
/
SongList.h
111 lines (90 loc) · 2.5 KB
/
SongList.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//Created by Elon Skolnik on 12/1/18.
#ifndef COMP220_SONGLIST_H
#define COMP220_SONGLIST_H
#include <stdexcept>
#include <string>
#include "Song.h"
#include "List.h"
class SongList : public List {
private:
//pointer to the start of the array
Song **array;
//count of the number of valid items currently stored in the array
int currItemCount;
//size of the current array
int currCapacity;
/**
* replaces the old array with an array twice the size
* private method only called within ArrayList when necessary
* @post: array points to a new array of twice the size with values copied from the old one,
* the old array is deleted.
*/
void doubleCapacity();
public:
/**
* Constructor
* @throws an std::invalid_argument exception if size < 1
*/
SongList(int initialCapacity);
//Destructor
~SongList();
/**
* appends the new item to the end of the list
* @post the list has an additional value in it, at the end
*/
void addSong(Song *songToAdd);
/**
* @inserts a son at a given index
*/
void insertAt(Song *itemToAdd, int index);
/**
* @adds a song to the list alphabetically
*/
void addAlphabetical(Song *songToAdd);
/**
* gives a string representation of the current list
* @returns a string representing the given list in the exact format shown below
* {1, 2, 3, 4, 5}
*/
std::string toString();
/**
* checks if there are any valid items in the list
* @return true if there are no valid items in the list, false otherwise
*/
bool isEmpty();
/**
* returns a count of valid items currently in the list
* @returns the number of valid items in the list
*/
int itemCount();
/**
* makes the list empty of valid items
* @post the list is empty, such that isEmpty() == true
*/
void clearList();
/**
* @return a string of all the songs by a particular artist
*/
std::string findArtist(std::string artist);
/**
* @removes a value at index
*/
void removeValueAt(int index);
/**
* @return the index of a song
*/
int findSong(std::string title, std::string artist);
/**
* @removes a song
*/
void removeSong(std::string title, std::string artist);
/**
* @returns value at a certain index
*/
Song* getValueAt(int index);
/**
* @returns the duration
*/
float calcDuration();
};
#endif //COMP220_SONGLIST_H