Artwork Class Hierarchy

Write a class Artwork and then create child classes Painting, Sculpture, Photograph, each with a unique method description that returns a brief description of the respective artwork.

Example 1:

Input: Painting 
Output: "Painting: A visual art form featuring impressions or expressions of a person, thing or nature on a surface such as canvas or paper."

Example 2:

Input: Sculpture 
Output: "Sculpture: A three-dimensional artwork created by shaping or combining hard, plastic material, sound, text, light, commonly stone (either rock or marble), metal, or wood."

Implement a method description in each of the child classes that returns the respective descriptions of the artwork.

class Artwork:
    def description(self):
        pass

class Painting(Artwork):
    def description(self):
        return "Painting: A visual art form featuring impressions or expressions of a person, thing or nature on a surface such as canvas or paper."

class Sculpture(Artwork):
    def description(self):
        return "Sculpture: A three-dimensional artwork created by shaping or combining hard, plastic material, sound, text, light, commonly stone (either rock or marble), metal, or wood."

class Photograph(Artwork):
    def description(self):
        return "Photograph: An image created by light falling on a photosensitive surface."

# Test the classes
painting = Painting()
print(painting.description())

sculpture = Sculpture()
print(sculpture.description())

photograph = Photograph()
print(photograph.description())

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!