I am writing a program with Artist and Artwork classes and a main.py file to run both classes. First I want to 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 "unknown" and the years of birth and death to -1. Then 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 "unknown", the year created to -1, and the artist to use the Artist default constructor parameter values. Add an import statement to import the Artist class. Finally, add import statements to main.py to import the Artist and Artwork classes. I have a working program that outputs the information but when I put in -1 to get unknown it initializes with -1 instead of printing unknown. I also need to add a repeating question to the user if they would like to add another artist that reruns the program if they type yes and prints bye bye if they type no.  This is the code I have so far: Artist.py class Artist:     def __init__(self, name="unknown", birth_year=-1, death_year=-1):         self.name = name         self.birth_year = birth_year         self.death_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))   Artwork.py from Artist import Artist class Artwork:     def __init__(self, user_title="unknown", year_created=-1, user_artist=Artist()):         self.title = user_title         self.year_created = year_created         self.artist = user_artist     def print_info(self):         self.artist.print_info()         print (f'Title: {self.title}, {self.year_created}') main.py from Artist import Artist from Artwork import Artwork if __name__ == "__main__":     print("Enter the artist's information")     user_artist_name = input()     user_birth_year = input()     user_death_year = input()     print("Enter the artwork information")     user_title = input()     user_year_created = 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()

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

I am writing a program with Artist and Artwork classes and a main.py file to run both classes. First I want to 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 "unknown" and the years of birth and death to -1.

Then 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 "unknown", the year created to -1, and the artist to use the Artist
default constructor parameter values. Add an import statement to import the
Artist class.

Finally, add import statements to main.py to import the Artist and Artwork classes.

I have a working program that outputs the information but when I put in -1 to get unknown it initializes with -1 instead of printing unknown. I also need to add a repeating question to the user if they would like to add another artist that reruns the program if they type yes and prints bye bye if they type no. 

This is the code I have so far:

Artist.py

class Artist:
    def __init__(self, name="unknown", birth_year=-1, death_year=-1):
        self.name = name
        self.birth_year = birth_year
        self.death_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))
 

Artwork.py

from Artist import Artist

class Artwork:
    def __init__(self, user_title="unknown", year_created=-1, user_artist=Artist()):
        self.title = user_title
        self.year_created = year_created
        self.artist = user_artist

    def print_info(self):
        self.artist.print_info()
        print (f'Title: {self.title}, {self.year_created}')

main.py

from Artist import Artist
from Artwork import Artwork

if __name__ == "__main__":
    print("Enter the artist's information")
    user_artist_name = input()
    user_birth_year = input()
    user_death_year = input()
    print("Enter the artwork information")
    user_title = input()
    user_year_created = 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()
    

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education