-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtPod.h
153 lines (97 loc) · 2.96 KB
/
UtPod.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//
// UtPod.h
//
//
// Created by David Fernandez and Adrian Melo on 10/28/18.
//
#ifndef UTPOD_H
#define UTPOD_H
#include "song.h"
//UtPod class declaration
class UtPod
{
private:
static const int MAX_MEMORY = 512;
static const int SUCCESS = 0;
static const int NO_MEMORY = -1;
static const int NOT_FOUND = -2;
struct SongNode
{
Song s;
SongNode *next;
SongNode():s(),next(NULL){} //default constructor for Song Node
};
SongNode *songs = NULL; //the head pointer
int memSize;
public:
//Default constructor
//set the memory size to MAX_MEMORY
UtPod();
//Constructor with size parameter
//The user of the class will pass in a size.
//If the size is greater than MAX_MEMORY or less than or equal to 0,
//set the size to MAX_MEMORY.
UtPod(int size);
/* FUNCTION - int addSong
* attempts to add a new song to the UtPod
o returns a 0 if successful
o returns -1 if not enough memory to add the song
precondition: s is a valid Song
input parms -
output parms -
*/
int addSong(Song const &s);
/* FUNCTION - int removeSong
* attempts to remove a song from the UtPod
* removes the first instance of a song that is in the the UtPod multiple times
o returns 0 if successful
o returns -1 if nothing is removed
input parms -
output parms -
*/
int removeSong(Song const &s);
/* FUNCTION - void shuffle
* shuffles the songs into random order
o will do nothing if there are less than two songs in the current list
input parms -
output parms -
*/
void shuffle();
/* FUNCTION - void showSongList
* prints the current list of songs in order from first to last to standard output
* format - Title, Artist, size in MB (one song per line)
input parms -
output parms -
*/
void showSongList();
/* FUNCTION - void sortSongList
* sorts the songs in ascending order
o will do nothing if there are less than two songs in the current list
input parms -
output parms -
*/
void sortSongList();
/* FUNCTION - void clearMemory
* clears all the songs from memory
input parms -
output parms -
*/
void clearMemory();
/* FUNCTION - int getTotalMemory
* returns the total amount of memory in the UtPod
o will do nothing if there are less than two songs in the current list
input parms -
output parms -
*/
int getTotalMemory() {
return memSize;
}
/* FUNCTION - int getRemainingMemory
* returns the amount of memory available for adding new songs
input parms -
output parms -
*/
int getRemainingMemory();
~UtPod();
};
#endif /* UtPod_h */