Toggle navigation
Toggle navigation
This project
Loading...
Sign in
안형준
/
Ds_worked
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
안형준
2018-11-22 12:59:14 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
09d55acdf8bf6c96730784f38b8579f8e574b9f4
09d55acd
1 parent
611beeab
현재까지 만든기능은 충돌이 발견되지 않음. 재생기능과 재생목록에서 재생기능추가함.
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
142 additions
and
9 deletions
Project/Application.cpp
Project/Application.h
Project/MusicType.h
Project/PLType.cpp
Project/SortedLinkedList.h
Project/Application.cpp
View file @
09d55ac
...
...
@@ -59,6 +59,9 @@ void Application::Run()
case
22
:
PrintPL
();
break
;
case
30
:
Play
();
break
;
case
98
:
ReadDataFromFile
();
break
;
...
...
@@ -245,6 +248,31 @@ void Application::Update()
data
.
SetPkey
();
//데이터를 변경했으므로 Pkey를 다시 지정해준다.
m_List
.
Add
(
data
);
cout
<<
"
\t
수정을 완료했습니다."
<<
endl
;
//수정을 성공했을 때 메시지를 출력한다.
DoublyIter
<
MusicType
>
Miter
(
m_List
);
while
(
Miter
.
NotNull
())
{
if
(
Miter
.
GetCurrentNode
().
data
==
data
)
{
MusicType
*
mptr
;
mptr
=
Miter
.
GetCurrentPtr
();
DoublyIter2
<
ManageType
>
Mgiter
(
mg_List
);
while
(
Mgiter
.
NotNull
())
{
if
(
Mgiter
.
GetCurrentNode
().
data
.
getPkey
()
==
data
.
GetPkey
())
{
ManageType
*
mgptr
;
mgptr
=
Mgiter
.
GetCurrentPtr
();
mgptr
->
setPtr
(
mptr
);
}
Mgiter
.
Next
();
}
}
Miter
.
Next
();
}
RemakeSubList
();
//MusicList에 변화가 생겼으므로 하위 리스트들을 다시 만들어줘야 한다.
if
(
m_List
.
GetLength
()
!=
0
)
//길이가 0이면 인덱스를 부여할수 없다.
{
...
...
@@ -476,10 +504,11 @@ void Application::DIsplayNewMusic()
DoublyIter2
<
ManageType
>
Mgiter
(
mg_List
);
Mgiter
.
Last
();
cout
<<
"이 아래로 터지는 이유를 찾아야함"
<<
endl
;
while
(
Mgiter
.
NotNull
()
&&
cnt
<
30
)
{
Mgiter
.
GetCurrentNode
().
data
.
PrintNameNIndex
();
NodeType2
<
ManageType
>
temp1
=
Mgiter
.
GetCurrentNode
();
ManageType
temp2
=
temp1
.
data
;
temp2
.
PrintNameNIndex
();
Mgiter
.
Prev
();
cnt
++
;
}
...
...
@@ -531,8 +560,9 @@ void Application::DisplayMusicbyGenre()
if
(
thisGenre
==
Miter2
.
GetCurrentNode
().
data
.
GetGenre
())
{
cout
<<
"트랙넘버 : "
<<
Miter2
.
GetCurrentNode
().
data
.
GetName
()
<<
endl
;
cout
<<
"곡명 : "
<<
Miter2
.
GetCurrentNode
().
data
.
GetName
()
<<
endl
;
cout
<<
"Index : "
<<
Miter2
.
GetCurrentNode
().
data
.
GetNum
()
<<
endl
;
}
Miter2
.
Next
();
}
...
...
@@ -615,8 +645,9 @@ void Application::DisplayMusicByAlbum()
if
(
Miter2
.
GetCurrentNode
().
data
.
GetAlbum
()
==
Abiter
.
GetCurrentNode
().
data
.
GetAlbumName
()
&&
Miter2
.
GetCurrentNode
().
data
.
GetSinger
()
==
Abiter
.
GetCurrentNode
().
data
.
GetArtistName
())
{
cout
<<
"
\t
트랙넘버 : "
<<
Miter2
.
GetCurrentNode
().
data
.
GetName
()
<<
endl
;
cout
<<
"
\t
곡명 : "
<<
Miter2
.
GetCurrentNode
().
data
.
GetName
()
<<
endl
;
cout
<<
"
\t
Index : "
<<
Miter2
.
GetCurrentNode
().
data
.
GetNum
()
<<
endl
;
}
Miter2
.
Next
();
...
...
@@ -804,6 +835,7 @@ void Application::PrintPL()
{
ptr
=
PLiter2
.
GetCurrentPtr
();
ptr
->
Printall
();
while
(
1
)
{
int
temp
;
...
...
@@ -811,11 +843,69 @@ void Application::PrintPL()
cin
>>
temp
;
if
(
temp
==
0
)
break
;
Play
(
temp
);
}
}
PLiter2
.
Next
();
}
}
void
Application
::
Play
()
{
if
(
RemakeListForPlay
==
true
)
//곡 리스트에 변경이 생겼을 경우 ListForPlay를 다시 만들어준다
{
delete
[]
ListforPlay
;
int
length
=
m_List
.
GetLength
();
ListforPlay
=
new
MusicType
*
[
length
];
DoublyIter
<
MusicType
>
Miter
(
m_List
);
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
ListforPlay
[
i
]
=
Miter
.
GetCurrentPtr
();
Miter
.
Next
();
}
RemakeListForPlay
=
false
;
}
cout
<<
"재생할 곡의 Index를 입력해주세요. "
<<
endl
;
int
cmdIndex
;
cin
>>
cmdIndex
;
if
(
cmdIndex
<
0
)
return
;
if
(
cmdIndex
>
m_List
.
GetLength
())
{
cout
<<
"잘못된 입력입니다"
<<
endl
;
return
;
}
ListforPlay
[
cmdIndex
-
1
]
->
cntPlayed
();
ListforPlay
[
cmdIndex
-
1
]
->
DisplayNameOnScreen
();
ListforPlay
[
cmdIndex
-
1
]
->
DisplaySingerOnScreen
();
cout
<<
"
\t
재생 횟수 : "
<<
ListforPlay
[
cmdIndex
-
1
]
->
DisplayPlayed
()
<<
endl
;
}
void
Application
::
Play
(
int
Index
)
{
if
(
RemakeListForPlay
==
true
)
//곡 리스트에 변경이 생겼을 경우 ListForPlay를 다시 만들어준다
{
delete
[]
ListforPlay
;
int
length
=
m_List
.
GetLength
();
ListforPlay
=
new
MusicType
*
[
length
];
DoublyIter
<
MusicType
>
Miter
(
m_List
);
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
ListforPlay
[
i
]
=
Miter
.
GetCurrentPtr
();
Miter
.
Next
();
}
RemakeListForPlay
=
false
;
}
int
cmdIndex
=
Index
;
ListforPlay
[
cmdIndex
-
1
]
->
cntPlayed
();
ListforPlay
[
cmdIndex
-
1
]
->
DisplayNameOnScreen
();
ListforPlay
[
cmdIndex
-
1
]
->
DisplaySingerOnScreen
();
cout
<<
"
\t
재생 횟수 : "
<<
ListforPlay
[
cmdIndex
-
1
]
->
DisplayPlayed
()
<<
endl
;
}
\ No newline at end of file
...
...
Project/Application.h
View file @
09d55ac
...
...
@@ -34,6 +34,7 @@ public:
RemakeAlbumList
=
true
;
RemakeArtistList
=
true
;
RemakeGenreList
=
true
;
RemakeListForPlay
=
true
;
NumofPL
=
0
;
}
...
...
@@ -283,6 +284,7 @@ public:
RemakeAlbumList
=
true
;
RemakeArtistList
=
true
;
RemakeGenreList
=
true
;
RemakeListForPlay
=
true
;
};
void
makePlayList
();
...
...
@@ -291,6 +293,11 @@ public:
void
PrintPL
();
void
Play
();
void
Play
(
int
Index
);
private
:
ifstream
m_InFile
;
///< input file descriptor.
ofstream
m_OutFile
;
///< output file descriptor.
...
...
@@ -302,9 +309,11 @@ private:
SortedLinkedList
<
string
>
GenreList
;
//장르를 분류하기 위한 장르 리스트
UnSortedLinkedList
<
PLType
>
PlayLists
;
//아래의 변수들은 각 하위 리스트를 다시만들어야 할지 판별하는 변수이다.
MusicType
**
ListforPlay
;
bool
RemakeAlbumList
;
bool
RemakeArtistList
;
bool
RemakeGenreList
;
bool
RemakeListForPlay
;
int
NumofPL
;
};
...
...
Project/MusicType.h
View file @
09d55ac
...
...
@@ -28,6 +28,7 @@ public:
Album
=
""
;
Genre
=
""
;
Lyrics
=
""
;
Played
=
0
;
}
/**
...
...
@@ -221,7 +222,7 @@ public:
*/
void
DisplaySingerOnScreen
()
{
cout
<<
"
\t
Singer
: "
<<
Singer
<<
endl
;
cout
<<
"
\t
Artist(Singer)
: "
<<
Singer
<<
endl
;
};
/**
...
...
@@ -369,7 +370,14 @@ public:
}
void
cntPlayed
()
{
Played
++
;
}
int
DisplayPlayed
()
{
return
Played
;
}
protected
:
int
Num
;
//곡의 인덱스
string
Name
;
//곡명
...
...
@@ -378,6 +386,7 @@ protected:
string
Genre
;
//장르
string
Lyrics
;
//가사
string
Pkey
;
//Primary Key
int
Played
;
//재생된 횟수
};
...
...
Project/PLType.cpp
View file @
09d55ac
...
...
@@ -13,8 +13,9 @@ void PLType::Printall()
DoublyIter2
<
ManageType
*>
Mgiter
(
PlayList
);
while
(
Mgiter
.
NotNull
())
{
cout
<<
" : "
<<
Mgiter
.
GetCurrentNode
().
data
->
getName
()
<<
endl
;
cout
<<
"Index : "
<<
Mgiter
.
GetCurrentNode
().
data
->
getIndex
()
<<
endl
;
//cout << " : " << Mgiter.GetCurrentNode().data->getName() << endl;
//cout << "Index : " << Mgiter.GetCurrentNode().data->getIndex() << endl;
Mgiter
.
GetCurrentNode
().
data
->
PrintNameNIndex
();
Mgiter
.
Next
();
}
...
...
Project/SortedLinkedList.h
View file @
09d55ac
...
...
@@ -288,7 +288,7 @@ int SortedLinkedList<T>::Delete(T& data)
int
positionIndex
=
Get
(
data
);
if
(
positionIndex
)
{
for
(
int
i
=
1
;
i
<
=
positionIndex
;
i
++
)
for
(
int
i
=
1
;
i
<
positionIndex
;
i
++
)
pNode
=
pNode
->
next
;
if
(
pNode
->
next
!=
NULL
)
...
...
@@ -349,6 +349,7 @@ int SortedLinkedList<T>::Replace(T& data)
template
<
typename
T
>
int
SortedLinkedList
<
T
>::
Get
(
T
&
data
)
{
/*
bool MoreToSearch, found;
NodeType<T>* location;
...
...
@@ -377,7 +378,30 @@ int SortedLinkedList<T>::Get(T& data)
{
return 0;
}
*/
DoublyIter
<
T
>
iter
(
*
this
);
int
count
=
0
;
// 몇 번째에 위치하고 있는지 리턴 (없으면 0)
// iterator를 사용하면서 curPointer를 재사용할 수 없으므로 return value의 의미를 변경
bool
found
=
false
;
while
(
iter
.
NotNull
())
{
count
++
;
if
(
data
==
iter
.
GetCurrentNode
().
data
)
{
found
=
true
;
data
=
iter
.
GetCurrentNode
().
data
;
break
;
}
else
if
(
data
<
iter
.
GetCurrentNode
().
data
)
break
;
else
iter
.
Next
();
}
if
(
found
)
return
count
;
else
return
0
;
}
...
...
Please
register
or
login
to post a comment