-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMMS.py
More file actions
78 lines (63 loc) · 1.87 KB
/
Copy pathMMS.py
File metadata and controls
78 lines (63 loc) · 1.87 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
import datetime
class Song:
def __init__(self,title,minutes,seconds,r_date):
self.title = title
self.minutes = minutes
self.seconds = seconds
self.r_date = r_date
def pr_song(self):
print(
f'The title of song is "{self.title}" '
f'and the duration is {self.minutes}:{self.seconds:02d} '
f'minutes and song released on {self.r_date}.')
class Artist:
def __init__(self,name):
self.name = name
self.songs = []
def add_songs(self,song):
self.songs.append(song)
def pr_artist(self):
print(f'Artist of these songs is: "{self.name}" | Songs are {len(self.songs)}')
class Musiclibrary():
def __init__(self,artist):
self.artist = []
self.songs = []
def add_artist(self,new_artist):
self.artist.append(new_artist)
def __str__(self):
return f"{self.name} ({len(self.songs)} songs)"
def find_artist(self,name):
if name in self.artist:
print(f'Artist found {name}')
else:
print(f'Artist not found {name}')
def add_songs(self, song_object):
self.songs.append(song_object)
def list_all_songs(self):
print("\n--- Library Song List ---")
for artist in self.artist:
artist.pr_artist()
for song in artist.songs:
song.pr_song()
kaavish = Artist('Kaavish')
atif = Artist('Atif')
kaavish.add_songs(Song('dekkho',
3,
45,
datetime.date(2008,3,1)))
kaavish.add_songs(Song('morey saiyan',
4,
5,
datetime.date(2008,3,1)))
atif.add_songs(
Song(
'Tery bin',
4,
13,
datetime.date(2006,8,7)
)
)
music_lib = Musiclibrary('Kaavish akr jaffar zaidi')
music_lib.add_artist(kaavish)
music_lib.add_artist(atif)
music_lib.list_all_songs()