-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDriver.cpp
More file actions
146 lines (110 loc) · 2.44 KB
/
Driver.cpp
File metadata and controls
146 lines (110 loc) · 2.44 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
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
// Play_list_manager.cpp : This file contains the 'main' function. Program execution begins and ends there.
#include <iostream>
#include "Song.h"
#include "PlayList.h"
using namespace std;
//function to call add song function
void DoAdd(playlist &play_list)
{
Song s;
cout << "Enter song\n: ";
//inputting object
cin >> s;
//calling function to add song
play_list.AddSong(s);
//calling function to show status
play_list.ShowStatus();
}
//function to call delete song function
void DoDelete(playlist &s1)
{
Song s2;
cout << "Enter song to delete\n: ";
cin >> s2;
//calling function to delete song
s1.DeleteSong(s2);
//function to show status
s1.ShowStatus();
}
void Add_by_Addition_operator(playlist list)
{
Song s;
cout << "Enter the song to add\n";
cin >> s;
list = list + s;
list.ShowStatus();
}
//function to delete song using - operator
void delete_by_subtraction_operator(playlist list)
{
Song s;
cout << "Enter the song to delete\n";
cin >> s;
list = list - s;
list.ShowStatus();
}
//function for selection menu
bool Menu(playlist &play_list)
{
bool good;
do
{
good = true;
cout << "\n\nPlayList Program!\n"
<< "\tA - Add a song\n"
<< "\tD - Delete a song\n"
<< "\tP - Play a song\n"
<< "\tS - Show all songs\n"
<< "\ts - Show Status\n"
<< "\t+ - Add song by addition operator\n"
<< "\t- - Delete song by subtraction operator\n"
<< "\tQ - Quit\n: ";
char choice;
//inputting the selection letter
cin >> choice;
switch (choice)
{
//case to add song
case 'A':
DoAdd(play_list);
break;
//case to delete song
case 'D':
DoDelete(play_list);
break;
//case to play songs
case 'P':
play_list.play(2);
break;
//case to show all songs
case 'S':
play_list.ShowAll();
break;
//case to show array size , no of songs and current song index
case 's':
play_list.ShowStatus();
break;
//Case to add song using + operator
case '+':
Add_by_Addition_operator(play_list);
break;
case '-':
delete_by_subtraction_operator(play_list);
break;
case 'Q':
return false;
default:
good = false;
}
} while (!good);
return true;
}
int main()
{
//declaring object
playlist play_list;
//calling function of menu
while (Menu(play_list))
;
return 0;
}