For my python assignment, I have to create classes and initialize them. I created them correctly but the automatic grader says they are not correctly initialized.
Define the Artist class with a constructor to initialize an artist's information and a print_info() method. The constructor should by default initialize the artist's name to "None" and the years of birth and death to 0. print_info() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise.
Define the Artwork class with a constructor to initialize an artwork's information and a print_info() method. The constructor should by default initialize the title to "None", the year created to 0, and the artist to use the Artist default constructor parameter values.
What I have so far:
class Artist:
def __init__(self, user_artist_name="None", user_birth_year=0, user_death_year=0):
self.name = user_artist_name
self.birth = user_birth_year
self.death = user_death_year
def print_info(self):
if self.death == -1:
print("Artist: {}, born {}".format(self.name, self.birth))
else:
print("Artist: {} ({}-{})".format(self.name, self.birth, self.death))
class Artwork:
def __init__(self, user_title= "None", year_created=0, user_artist=Artist()):
self.title = user_title
self.year = year_created
self.artist = user_artist
def print_info(self):
print("Title: {}, {}".format(self.title, self.year))
if __name__ == "__main__":
user_artist_name = input()
user_birth_year = int(input())
user_death_year = int(input())
user_title = input()
user_year_created = int(input())
user_artist = Artist(user_artist_name, user_birth_year, user_death_year)
user_artist.print_info()
new_artwork = Artwork(user_title, user_year_created, user_artist)
new_artwork.print_info()
Artist('Pablo Picasso', 1881, 1973) fails to correctly initialize artist. and the constructor for both default parameters of Artist and Artwork fail.
What am I missing?