The lab doesn't compile completely Define the Artist class in Artist.py with a constructor to initialize an artist's information. The constructor should by default initialize the artist's name to...


The lab doesn't compile completely


Define the Artist class in Artist.py with a constructor to initialize an artist's information. The constructor should by default initialize the artist's name to "None" and the years of birth and death to 0.


Define the Artwork class in Artwork.py with a constructor to initialize an artwork's information. 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. Add an import statement to import the Artist class.


Add import statements to main.py to import the Artist and Artwork classes.


Ex: If the input is:


Pablo Picasso 1881 1973 Three Musicians 1921


the output is:


Artist: Pablo Picasso (1881-1973) Title: Three Musicians, 1921


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:
# TODO: Define constructor with parameters to initialize instance attributes
# (name, birth_year, death_year)


def print_info(self):
if self.death_year == -1:
print('Artist: {}, born {}'.format(self.name, self.birth_year))
else:
print('Artist: {} ({}-{})'.format(self.name, self.birth_year, self.death_year))


# TODO: Import Artist from Artist.py


class Artwork:
# TODO: Define constructor with parameters to initialize instance attributes
# (title, year_created, artist)


def print_info(self):
self.artist.print_info()
print('Title: %s, %d' % (self.title, self.year_created))


# TODO: Import Artist from Artist.py and Artwork from Artwork.py


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)


new_artwork = Artwork(user_title, user_year_created, user_artist)


new_artwork.print_info()


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()


This is what I get when I execute the code:  The foutr test fail to execute




1: Compare outputkeyboard_arrow_up

1 / 1



Input

Pablo Picasso 1881 1973 Three Musicians 1921



Your output

Artist: Pablo Picasso (1881-1973) Title: Three Musicians, 1921






2: Compare outputkeyboard_arrow_up

1 / 1



Input

Brice Marden 1938 -1 Distant Muses 2000



Your output

Artist: Brice Marden, born 1938 Title: Distant Muses, 2000






3: Unit testkeyboard_arrow_up

0 / 2


Tests Artist constructor with default param values





4: Unit testkeyboard_arrow_up

0 / 2


Tests that Artist('Pablo Picasso', 1881, 1973) correctly initializes artist





5: Unit testkeyboard_arrow_up

0 / 2


Tests that Artist('Brice Marden', 1938, -1) correctly initializes artist





6: Unit testkeyboard_arrow_up

0 / 2


Tests Artwork constructor with default param values


Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here