forked from ASD-ADF/ASD_Task_4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
174 lines (158 loc) · 3.77 KB
/
main.cpp
File metadata and controls
174 lines (158 loc) · 3.77 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
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
#include "player.h"
List L;
address P;
infotype x;
int index_ID,n;
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 = "";
x.name = "clapping.wav";
P = alokasi(x);
insertFirst(L,P);
x.ID = index_ID++;
x.location = "";
x.name = "airpump2.wav";
P = alokasi(x);
insertFirst(L,P);
//-----------------------------------------
// memanggil menu utama
//-----------------------------------------
menu();
return 0;
}
void menu()
{
/**
* prosedur menu utama
*/
int pil;
do
{
displayMenu();
cin>>pil;
runMenu(pil);
}
while (pil!=12);
}
void displayMenu()
{
/**
* prosedur menampilkan pilihan menu
* TODO : modifikasi menu sehingga juga menampilkan menu:
* - search song
* - play previous
* - play again the last song played
* - shuffle list
* - sort the song
* - play repeat all
*/
//-------------your code here-------------
cout<<"1. Input new Song "<<endl
<<"2. View list"<<endl
<<"3. Search song"<<endl
<<"4. Sort the Song"<<endl
<<"5. Shuffle List"<<endl
<<"6. Play first song"<<endl
<<"7. Play again the last song played"<<endl
<<"8. Play next "<<endl
<<"9. Play Prev"<<endl
<<"10. Play Repeat All"<<endl
<<"11. Delete Song"<<endl
<<"12. Exit"<<endl;
cout<<"choose menu : ";
//----------------------------------------
}
void runMenu(int menu)
{
/**
* prosedur memproses input pilihan menu dari user
* TODO : modifikasi menu sehingga juga memproses menu:
* - search song
* - play previous
* - play again the last song played
* - shuffle list
* - sort the song
* - play repeat all
*/
//-------------your code here-------------
int pil;
switch(menu)
{
case 1 :
cout<<"input new song : "<<endl;
inputNewSong(x);
x.ID = index_ID++;
P = alokasi(x);
insertFirst(L,P);
break;
case 2:
printInfo(L);
break;
case 3:
cout <<"Masukkan Judul Lagu (.wav) : "<<endl;
cin >> x.name;
P = findElm(L,x);
cout <<"Judul Lagu : "<<Info(P).name<<endl;
cout <<"Lokasi : "<<Info(P).location<<endl;
playSong(P);
cout <<endl
<<endl;
break;
case 4 :
cout <<"1. Sort byID"<<endl
<<"2. Sort byName"<<endl
<<"sorting berdasarkan : ";
cin >> pil;
cout << endl;
if (pil == 1 or pil == 2)
{
sortList(L,pil);
cout <<endl;
}
else
{
cout <<"input salah";
}
break;
case 5 :
shuffleList(L);
printInfo(L);
break;
case 6:
P = First(L);
playSong(P);
break;
case 7:
playSong(P);
break;
case 8:
playNext(P);
break;
case 9:
playPrev(P);
break;
case 10:
cout <<"repeat sebanyak : ";
cin >> n;
playRepeat(L, n);
break;
case 11:
deleteSong(L);
break;
case 12:
cout<<"terima kasih"<<endl;
break;
default :
cout<<"input salah"<<endl;
}
//----------------------------------------
}