-
Notifications
You must be signed in to change notification settings - Fork 208
/
Copy pathmain.cpp
215 lines (193 loc) · 4.96 KB
/
main.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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#include "player.h"
#include "list.h"
#include <conio.h>
List L;
address P;
infotype x;
int index_ID;
void menu();
void displayMenu();
void runMenu(int menu);
int main() {
index_ID = 1;
createList(L);
//-----------------------------------------
// example of data initialization
//-----------------------------------------
x.ID = index_ID++;
x.location = "asset";
x.name = "do.wav";
P = allocate(x);
insertFirst(L,P);
x.ID = index_ID++;
x.location = "asset";
x.name = "re.wav";
P = allocate(x);
insertLast(L,P);
x.ID = index_ID++;
x.location = "asset";
x.name = "mi.wav";
P = allocate(x);
insertLast(L,P);
//-----------------------------------------
// view data
//-----------------------------------------
printInfo(L);
//-----------------------------------------
// call main menu
//-----------------------------------------
menu();
return 0;
}
void menu() {
/**
* MAIN MENU PROCEDURE
* YOU DON'T NEED TO MODIFY THIS
*/
int pil;
do {
displayMenu();
cin>>pil;
runMenu(pil);
} while (pil!=0);
}
void displayMenu() {
/**
* PROCEDURE TO SHOW THE MENU TEXT
* YOU DON'T NEED TO MODIFY THIS
*/
cout<<"======================MENU====================="<<endl
<<"1. insert first music"<<endl
<<"2. insert last music"<<endl
<<"3. view music list"<<endl
<<"4. play first music"<<endl
<<"5. play last music"<<endl
<<"6. search music by name"<<endl
<<"7. search music by ID"<<endl
<<"8. play current music"<<endl
<<"9. play next music"<<endl
<<"10. play previous music"<<endl
<<"11. shuffle list"<<endl
<<"12. play repeat all music"<<endl
<<"13. delete music by ID"<<endl
<<"0. exit"<<endl;
cout<<"choose menu : ";
}
address inputMusic() {
/**
* PR : ASKS USER INPUT TO FILL THE MUSIC NAME AND LOCATION
* FS : ALLOCATE AND RETURN THE ADDRESS OF THE ELEMENT
* YOU DON'T NEED TO MODIFY THIS
*/
cout<<"input music filename (.wav) : ";
cin>>x.name;
cout<<"input music location "<<endl<<"(write - for default /asset location) :";
cin>>x.location;
if(x.location=="-") {
x.location="asset";
}
x.ID = index_ID++;
return allocate(x);
}
void runMenu(int menu) {
/**
* PROCESS MENU ACCORDING TO USER CHOICE
* TODO : MODIFY THE CODE TO PROCESS USER CHOICE
*/
switch(menu) {
case 1:
// insert first music
P = inputMusic();
insertFirst(L,P);
cout<<"press enter";getche();
break;
case 2:
// insert last music
//------------- YOUR CODE HERE -------------
cout<<"UNDER MAIN TENIS"<<endl;
//input music
//insertLast()
//----------------------------------------
cout<<"press enter";getche();
break;
case 3:
// view music list
printInfo(L);
cout<<"press enter";getche();
break;
case 4:
// play first music
P = first(L);
playMusic(P);
break;
case 5:
// play last music
//------------- YOUR CODE HERE -------------
cout<<"UNDER MAIN TENIS"<<endl;
//----------------------------------------
break;
case 6:
// search music by name
//------------- YOUR CODE HERE -------------
cout<<"input music filename (.wav) : ";
cin>>x.name;
P = findElmByName(L, x);
if(P != NULL){
cout<<"music found"<<endl;
}
//----------------------------------------
cout<<"press enter";getche();
break;
case 7:
// search music by ID
//------------- YOUR CODE HERE -------------
cout<<"UNDER MAIN TENIS"<<endl;
//----------------------------------------
cout<<"press enter";getche();
break;
case 8:
// play current music
if(P!=NULL) {
playMusic(P);
}
break;
case 9:
// play next music
if(P!=NULL) {
P = next(P);
playMusic(P);
}
break;
case 10:
// play previous music
//------------- YOUR CODE HERE -------------
cout<<"UNDER MAIN TENIS"<<endl;
//----------------------------------------
break;
case 11:
// shuffle list
shuffleList(L);
cout<<"press enter";getche();
break;
case 12:
// play repeat all music
int n;
cout<<"input repeat times : ";
cin>>n;
playRepeat(L,n);
cout<<"press enter";getche();
break;
case 13:
// delete music by ID
cout<<"input music ID : ";
cin>>x.name;
deleteMusicByID(L, x);
cout<<"press enter";getche();
break;
case 0:
cout<<"thank you"<<endl;
break;
default :
cout<<"wrong input"<<endl;
}
}