-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ18 import artist from artist.py and artwork from artwork.py
More file actions
52 lines (41 loc) · 1.31 KB
/
Copy pathQ18 import artist from artist.py and artwork from artwork.py
File metadata and controls
52 lines (41 loc) · 1.31 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
# If the input is:
# Brice Marden
# 1938
# -1
# Distant Muses
# 2000
# The output is:
# Artist: Brice Marden, born 1938
# Title: Distant Muses, 2000
class Artist:
def __init__(self, name = "None", birthYear = 0, deathYear = 0):
self.name = name
self.birthYear = birthYear
self.deathYear = deathYear
def displayInfo(self):
if self.deathYear == -1:
print('Artist: {}, born {}'.format(self.name, self.birthYear))
else:
print('Artist: {} ({}---{})'.format(self.name, self.birthYear, self.deathYear))
class Artwork:
def __init__(self, title = "None", yearCreated =0, artist = Artist()):
self.title = title
self.yearCreated = yearCreated
self.artist = artist
def displayInfo(self):
self.artist.displayInfo()
print("Title: %s. %d" % (self.title, self.yearCreated))
# import artist from artist.py and artwork from artwork.py
from Artist import *
from Artwork import *
# the user input will be
if ___name___ == "___main___":
artistName = input()
birthYear = input ()
deathYear = input ()
title = input ()
yearCreated = int(input())
# the method to call displayInfo
userArtist = Artist(artistName, birthYear, deathYear)
artwork = Artwork(title, yearCreated, userArtist)
artwork.displayInfo()