-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlaylist.cpp
59 lines (47 loc) · 1.11 KB
/
Playlist.cpp
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
/*
Alexis Reeves, Section 02, [email protected]
Description: Contains public functions for class Playlist.
Done without pair programming and in Visual Studio.
Freed memory in main.cpp on lines 156, 175
Late Days: none
*/
#include <iostream>
#include <vector>
#include "Playlist.h"
using namespace std;
Playlist::Playlist(string name) {
this->name = name;
}
string Playlist::GetName() const {
return this->name;
}
void Playlist::AddSong(Song* songChoice) {
list.push_back(songChoice);
return;
}
void Playlist::Play() const {
for(int i = 0; i < list.size(); ++i) {
cout << list.at(i)->GetLine() << endl;
list.at(i)->AddTimesPlayed();
}
return;
}
void Playlist::DeleteSong(int songChoice) {
list.erase(list.begin() + songChoice);
return;
}
void Playlist::List() const {
for(int i = 0; i < list.size(); ++i) {
cout << i << ": " << list.at(i)->GetName() << endl;
}
return;
}
void Playlist::Delete(string songName) {
for(int i = 0; i < list.size(); ++i) {
if(songName == list.at(i)->GetName()) {
DeleteSong(i);
--i;
}
}
return;
}