Showing
5 changed files
with
142 additions
and
9 deletions
... | @@ -59,6 +59,9 @@ void Application::Run() | ... | @@ -59,6 +59,9 @@ void Application::Run() |
59 | case 22: | 59 | case 22: |
60 | PrintPL(); | 60 | PrintPL(); |
61 | break; | 61 | break; |
62 | + case 30: | ||
63 | + Play(); | ||
64 | + break; | ||
62 | case 98: | 65 | case 98: |
63 | ReadDataFromFile(); | 66 | ReadDataFromFile(); |
64 | break; | 67 | break; |
... | @@ -245,6 +248,31 @@ void Application::Update() | ... | @@ -245,6 +248,31 @@ void Application::Update() |
245 | data.SetPkey(); //데이터를 변경했으므로 Pkey를 다시 지정해준다. | 248 | data.SetPkey(); //데이터를 변경했으므로 Pkey를 다시 지정해준다. |
246 | m_List.Add(data); | 249 | m_List.Add(data); |
247 | cout << "\t수정을 완료했습니다." << endl; //수정을 성공했을 때 메시지를 출력한다. | 250 | cout << "\t수정을 완료했습니다." << endl; //수정을 성공했을 때 메시지를 출력한다. |
251 | + DoublyIter<MusicType> Miter(m_List); | ||
252 | + while (Miter.NotNull()) | ||
253 | + { | ||
254 | + if (Miter.GetCurrentNode().data == data) | ||
255 | + { | ||
256 | + MusicType* mptr; | ||
257 | + mptr = Miter.GetCurrentPtr(); | ||
258 | + DoublyIter2<ManageType> Mgiter(mg_List); | ||
259 | + while (Mgiter.NotNull()) | ||
260 | + { | ||
261 | + if (Mgiter.GetCurrentNode().data.getPkey() == data.GetPkey()) | ||
262 | + { | ||
263 | + ManageType* mgptr; | ||
264 | + mgptr = Mgiter.GetCurrentPtr(); | ||
265 | + mgptr->setPtr(mptr); | ||
266 | + | ||
267 | + } | ||
268 | + Mgiter.Next(); | ||
269 | + } | ||
270 | + | ||
271 | + } | ||
272 | + Miter.Next(); | ||
273 | + } | ||
274 | + | ||
275 | + | ||
248 | RemakeSubList(); //MusicList에 변화가 생겼으므로 하위 리스트들을 다시 만들어줘야 한다. | 276 | RemakeSubList(); //MusicList에 변화가 생겼으므로 하위 리스트들을 다시 만들어줘야 한다. |
249 | if (m_List.GetLength() != 0) //길이가 0이면 인덱스를 부여할수 없다. | 277 | if (m_List.GetLength() != 0) //길이가 0이면 인덱스를 부여할수 없다. |
250 | { | 278 | { |
... | @@ -476,10 +504,11 @@ void Application::DIsplayNewMusic() | ... | @@ -476,10 +504,11 @@ void Application::DIsplayNewMusic() |
476 | DoublyIter2<ManageType> Mgiter(mg_List); | 504 | DoublyIter2<ManageType> Mgiter(mg_List); |
477 | Mgiter.Last(); | 505 | Mgiter.Last(); |
478 | 506 | ||
479 | - cout << "이 아래로 터지는 이유를 찾아야함" << endl; | ||
480 | while (Mgiter.NotNull() && cnt < 30) | 507 | while (Mgiter.NotNull() && cnt < 30) |
481 | { | 508 | { |
482 | - Mgiter.GetCurrentNode().data.PrintNameNIndex(); | 509 | + NodeType2<ManageType> temp1 = Mgiter.GetCurrentNode(); |
510 | + ManageType temp2 = temp1.data; | ||
511 | + temp2.PrintNameNIndex(); | ||
483 | Mgiter.Prev(); | 512 | Mgiter.Prev(); |
484 | cnt++; | 513 | cnt++; |
485 | } | 514 | } |
... | @@ -531,8 +560,9 @@ void Application::DisplayMusicbyGenre() | ... | @@ -531,8 +560,9 @@ void Application::DisplayMusicbyGenre() |
531 | 560 | ||
532 | if (thisGenre == Miter2.GetCurrentNode().data.GetGenre()) | 561 | if (thisGenre == Miter2.GetCurrentNode().data.GetGenre()) |
533 | { | 562 | { |
534 | - cout << "트랙넘버 : " << Miter2.GetCurrentNode().data.GetName() << endl; | 563 | + |
535 | cout << "곡명 : " << Miter2.GetCurrentNode().data.GetName() << endl; | 564 | cout << "곡명 : " << Miter2.GetCurrentNode().data.GetName() << endl; |
565 | + cout << "Index : " << Miter2.GetCurrentNode().data.GetNum() << endl; | ||
536 | } | 566 | } |
537 | Miter2.Next(); | 567 | Miter2.Next(); |
538 | } | 568 | } |
... | @@ -615,8 +645,9 @@ void Application::DisplayMusicByAlbum() | ... | @@ -615,8 +645,9 @@ void Application::DisplayMusicByAlbum() |
615 | 645 | ||
616 | if (Miter2.GetCurrentNode().data.GetAlbum() == Abiter.GetCurrentNode().data.GetAlbumName() && Miter2.GetCurrentNode().data.GetSinger() == Abiter.GetCurrentNode().data.GetArtistName()) | 646 | if (Miter2.GetCurrentNode().data.GetAlbum() == Abiter.GetCurrentNode().data.GetAlbumName() && Miter2.GetCurrentNode().data.GetSinger() == Abiter.GetCurrentNode().data.GetArtistName()) |
617 | { | 647 | { |
618 | - cout << "\t트랙넘버 : " << Miter2.GetCurrentNode().data.GetName() << endl; | ||
619 | cout << "\t곡명 : " << Miter2.GetCurrentNode().data.GetName() << endl; | 648 | cout << "\t곡명 : " << Miter2.GetCurrentNode().data.GetName() << endl; |
649 | + cout << "\tIndex : " << Miter2.GetCurrentNode().data.GetNum() << endl; | ||
650 | + | ||
620 | 651 | ||
621 | } | 652 | } |
622 | Miter2.Next(); | 653 | Miter2.Next(); |
... | @@ -804,6 +835,7 @@ void Application::PrintPL() | ... | @@ -804,6 +835,7 @@ void Application::PrintPL() |
804 | { | 835 | { |
805 | ptr = PLiter2.GetCurrentPtr(); | 836 | ptr = PLiter2.GetCurrentPtr(); |
806 | ptr->Printall(); | 837 | ptr->Printall(); |
838 | + | ||
807 | while (1) | 839 | while (1) |
808 | { | 840 | { |
809 | int temp; | 841 | int temp; |
... | @@ -811,11 +843,69 @@ void Application::PrintPL() | ... | @@ -811,11 +843,69 @@ void Application::PrintPL() |
811 | cin >> temp; | 843 | cin >> temp; |
812 | if (temp == 0) | 844 | if (temp == 0) |
813 | break; | 845 | break; |
846 | + Play(temp); | ||
814 | } | 847 | } |
848 | + | ||
815 | } | 849 | } |
816 | PLiter2.Next(); | 850 | PLiter2.Next(); |
817 | } | 851 | } |
818 | 852 | ||
819 | 853 | ||
820 | 854 | ||
855 | +} | ||
856 | + | ||
857 | +void Application::Play() | ||
858 | +{ | ||
859 | + if (RemakeListForPlay == true) //곡 리스트에 변경이 생겼을 경우 ListForPlay를 다시 만들어준다 | ||
860 | + { | ||
861 | + delete[] ListforPlay; | ||
862 | + int length = m_List.GetLength(); | ||
863 | + ListforPlay = new MusicType*[length]; | ||
864 | + DoublyIter<MusicType> Miter(m_List); | ||
865 | + for (int i = 0; i < length; i++) | ||
866 | + { | ||
867 | + ListforPlay[i] = Miter.GetCurrentPtr(); | ||
868 | + Miter.Next(); | ||
869 | + } | ||
870 | + RemakeListForPlay = false; | ||
871 | + } | ||
872 | + cout << "재생할 곡의 Index를 입력해주세요. " << endl; | ||
873 | + int cmdIndex; | ||
874 | + cin >> cmdIndex; | ||
875 | + if (cmdIndex < 0) | ||
876 | + return; | ||
877 | + if (cmdIndex > m_List.GetLength()) | ||
878 | + { | ||
879 | + cout << "잘못된 입력입니다" << endl; | ||
880 | + return; | ||
881 | + } | ||
882 | + ListforPlay[cmdIndex - 1]->cntPlayed(); | ||
883 | + ListforPlay[cmdIndex - 1]->DisplayNameOnScreen(); | ||
884 | + ListforPlay[cmdIndex - 1]->DisplaySingerOnScreen(); | ||
885 | + cout << "\t재생 횟수 : " << ListforPlay[cmdIndex - 1]->DisplayPlayed() << endl; | ||
886 | +} | ||
887 | + | ||
888 | +void Application::Play(int Index) | ||
889 | +{ | ||
890 | + if (RemakeListForPlay == true) //곡 리스트에 변경이 생겼을 경우 ListForPlay를 다시 만들어준다 | ||
891 | + { | ||
892 | + delete[] ListforPlay; | ||
893 | + int length = m_List.GetLength(); | ||
894 | + ListforPlay = new MusicType*[length]; | ||
895 | + DoublyIter<MusicType> Miter(m_List); | ||
896 | + for (int i = 0; i < length; i++) | ||
897 | + { | ||
898 | + ListforPlay[i] = Miter.GetCurrentPtr(); | ||
899 | + Miter.Next(); | ||
900 | + } | ||
901 | + RemakeListForPlay = false; | ||
902 | + } | ||
903 | + int cmdIndex = Index; | ||
904 | + | ||
905 | + ListforPlay[cmdIndex - 1]->cntPlayed(); | ||
906 | + ListforPlay[cmdIndex - 1]->DisplayNameOnScreen(); | ||
907 | + ListforPlay[cmdIndex - 1]->DisplaySingerOnScreen(); | ||
908 | + cout << "\t재생 횟수 : " << ListforPlay[cmdIndex - 1]->DisplayPlayed() << endl; | ||
909 | + | ||
910 | + | ||
821 | } | 911 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -34,6 +34,7 @@ public: | ... | @@ -34,6 +34,7 @@ public: |
34 | RemakeAlbumList = true; | 34 | RemakeAlbumList = true; |
35 | RemakeArtistList = true; | 35 | RemakeArtistList = true; |
36 | RemakeGenreList = true; | 36 | RemakeGenreList = true; |
37 | + RemakeListForPlay = true; | ||
37 | NumofPL = 0; | 38 | NumofPL = 0; |
38 | 39 | ||
39 | } | 40 | } |
... | @@ -283,6 +284,7 @@ public: | ... | @@ -283,6 +284,7 @@ public: |
283 | RemakeAlbumList = true; | 284 | RemakeAlbumList = true; |
284 | RemakeArtistList = true; | 285 | RemakeArtistList = true; |
285 | RemakeGenreList = true; | 286 | RemakeGenreList = true; |
287 | + RemakeListForPlay = true; | ||
286 | }; | 288 | }; |
287 | 289 | ||
288 | void makePlayList(); | 290 | void makePlayList(); |
... | @@ -291,6 +293,11 @@ public: | ... | @@ -291,6 +293,11 @@ public: |
291 | 293 | ||
292 | void PrintPL(); | 294 | void PrintPL(); |
293 | 295 | ||
296 | + | ||
297 | + void Play(); | ||
298 | + | ||
299 | + void Play(int Index); | ||
300 | + | ||
294 | private: | 301 | private: |
295 | ifstream m_InFile; ///< input file descriptor. | 302 | ifstream m_InFile; ///< input file descriptor. |
296 | ofstream m_OutFile; ///< output file descriptor. | 303 | ofstream m_OutFile; ///< output file descriptor. |
... | @@ -302,9 +309,11 @@ private: | ... | @@ -302,9 +309,11 @@ private: |
302 | SortedLinkedList <string> GenreList; //장르를 분류하기 위한 장르 리스트 | 309 | SortedLinkedList <string> GenreList; //장르를 분류하기 위한 장르 리스트 |
303 | UnSortedLinkedList<PLType> PlayLists; | 310 | UnSortedLinkedList<PLType> PlayLists; |
304 | //아래의 변수들은 각 하위 리스트를 다시만들어야 할지 판별하는 변수이다. | 311 | //아래의 변수들은 각 하위 리스트를 다시만들어야 할지 판별하는 변수이다. |
312 | + MusicType** ListforPlay; | ||
305 | bool RemakeAlbumList; | 313 | bool RemakeAlbumList; |
306 | bool RemakeArtistList; | 314 | bool RemakeArtistList; |
307 | bool RemakeGenreList; | 315 | bool RemakeGenreList; |
316 | + bool RemakeListForPlay; | ||
308 | int NumofPL; | 317 | int NumofPL; |
309 | }; | 318 | }; |
310 | 319 | ... | ... |
... | @@ -28,6 +28,7 @@ public: | ... | @@ -28,6 +28,7 @@ public: |
28 | Album = ""; | 28 | Album = ""; |
29 | Genre = ""; | 29 | Genre = ""; |
30 | Lyrics = ""; | 30 | Lyrics = ""; |
31 | + Played = 0; | ||
31 | } | 32 | } |
32 | 33 | ||
33 | /** | 34 | /** |
... | @@ -221,7 +222,7 @@ public: | ... | @@ -221,7 +222,7 @@ public: |
221 | */ | 222 | */ |
222 | void DisplaySingerOnScreen() | 223 | void DisplaySingerOnScreen() |
223 | { | 224 | { |
224 | - cout << "\tSinger : " << Singer << endl; | 225 | + cout << "\tArtist(Singer) : " << Singer << endl; |
225 | }; | 226 | }; |
226 | 227 | ||
227 | /** | 228 | /** |
... | @@ -369,7 +370,14 @@ public: | ... | @@ -369,7 +370,14 @@ public: |
369 | 370 | ||
370 | } | 371 | } |
371 | 372 | ||
372 | - | 373 | + void cntPlayed() |
374 | + { | ||
375 | + Played++; | ||
376 | + } | ||
377 | + int DisplayPlayed() | ||
378 | + { | ||
379 | + return Played; | ||
380 | + } | ||
373 | protected: | 381 | protected: |
374 | int Num; //곡의 인덱스 | 382 | int Num; //곡의 인덱스 |
375 | string Name; //곡명 | 383 | string Name; //곡명 |
... | @@ -378,6 +386,7 @@ protected: | ... | @@ -378,6 +386,7 @@ protected: |
378 | string Genre; //장르 | 386 | string Genre; //장르 |
379 | string Lyrics; //가사 | 387 | string Lyrics; //가사 |
380 | string Pkey; //Primary Key | 388 | string Pkey; //Primary Key |
389 | + int Played; //재생된 횟수 | ||
381 | }; | 390 | }; |
382 | 391 | ||
383 | 392 | ... | ... |
... | @@ -13,8 +13,9 @@ void PLType::Printall() | ... | @@ -13,8 +13,9 @@ void PLType::Printall() |
13 | DoublyIter2<ManageType*> Mgiter(PlayList); | 13 | DoublyIter2<ManageType*> Mgiter(PlayList); |
14 | while (Mgiter.NotNull()) | 14 | while (Mgiter.NotNull()) |
15 | { | 15 | { |
16 | - cout << " : " << Mgiter.GetCurrentNode().data->getName() << endl; | 16 | + //cout << " : " << Mgiter.GetCurrentNode().data->getName() << endl; |
17 | - cout << "Index : " << Mgiter.GetCurrentNode().data->getIndex() << endl; | 17 | + //cout << "Index : " << Mgiter.GetCurrentNode().data->getIndex() << endl; |
18 | + Mgiter.GetCurrentNode().data->PrintNameNIndex(); | ||
18 | Mgiter.Next(); | 19 | Mgiter.Next(); |
19 | } | 20 | } |
20 | 21 | ... | ... |
... | @@ -288,7 +288,7 @@ int SortedLinkedList<T>::Delete(T& data) | ... | @@ -288,7 +288,7 @@ int SortedLinkedList<T>::Delete(T& data) |
288 | int positionIndex = Get(data); | 288 | int positionIndex = Get(data); |
289 | if (positionIndex) | 289 | if (positionIndex) |
290 | { | 290 | { |
291 | - for (int i = 1; i <= positionIndex; i++) | 291 | + for (int i = 1; i < positionIndex; i++) |
292 | pNode = pNode->next; | 292 | pNode = pNode->next; |
293 | 293 | ||
294 | if (pNode->next != NULL) | 294 | if (pNode->next != NULL) |
... | @@ -349,6 +349,7 @@ int SortedLinkedList<T>::Replace(T& data) | ... | @@ -349,6 +349,7 @@ int SortedLinkedList<T>::Replace(T& data) |
349 | template<typename T> | 349 | template<typename T> |
350 | int SortedLinkedList<T>::Get(T& data) | 350 | int SortedLinkedList<T>::Get(T& data) |
351 | { | 351 | { |
352 | + /* | ||
352 | bool MoreToSearch, found; | 353 | bool MoreToSearch, found; |
353 | NodeType<T>* location; | 354 | NodeType<T>* location; |
354 | 355 | ||
... | @@ -377,7 +378,30 @@ int SortedLinkedList<T>::Get(T& data) | ... | @@ -377,7 +378,30 @@ int SortedLinkedList<T>::Get(T& data) |
377 | { | 378 | { |
378 | return 0; | 379 | return 0; |
379 | } | 380 | } |
381 | + */ | ||
382 | + DoublyIter<T> iter(*this); | ||
383 | + int count = 0; // 몇 번째에 위치하고 있는지 리턴 (없으면 0) | ||
384 | + // iterator를 사용하면서 curPointer를 재사용할 수 없으므로 return value의 의미를 변경 | ||
385 | + bool found = false; | ||
386 | + while (iter.NotNull()) | ||
387 | + { | ||
388 | + count++; | ||
389 | + if (data == iter.GetCurrentNode().data) | ||
390 | + { | ||
391 | + found = true; | ||
392 | + data = iter.GetCurrentNode().data; | ||
393 | + break; | ||
394 | + } | ||
395 | + else if (data < iter.GetCurrentNode().data) | ||
396 | + break; | ||
397 | + else | ||
398 | + iter.Next(); | ||
399 | + } | ||
380 | 400 | ||
401 | + if (found) | ||
402 | + return count; | ||
403 | + else | ||
404 | + return 0; | ||
381 | 405 | ||
382 | 406 | ||
383 | } | 407 | } | ... | ... |
-
Please register or login to post a comment