Create a python program for the following details: Create an abstract class Shape Under Shape create abstract methods name, sides, and color. Create subclasses of Shape with the name Square, Pentagon, and Triangle. Under each subclass, implement the methods name, sides, and color with the following details. Square: print "Square", "I have 4 sides", "My color is yellow" Pentagon: print "Pentagon", "I have 5 sides", "My color is blue" Triangle: print "Triangle", "I have 3 sides", "My color is red" Create an instance of each subclasses. Ask the user for an input. (Assume the user will input 3, 4, or 5 only) if the user input 3 - print the details of an object of subclass Triangle if the user input 4 - print the details of an object of subclass Square if the user input 5 - print the details of an object of subclass Pentagon SAMPLE INPUT 1. num SAMPLE OUTPUT NEEDED: Enter a number: 3 Triangle I have 3 sides My color is red

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question

Create a python program for the following details: Create an abstract class Shape Under Shape create abstract methods name, sides, and color. Create subclasses of Shape with the name Square, Pentagon, and Triangle. Under each subclass, implement the methods name, sides, and color with the following details. Square: print "Square", "I have 4 sides", "My color is yellow" Pentagon: print "Pentagon", "I have 5 sides", "My color is blue" Triangle: print "Triangle", "I have 3 sides", "My color is red" Create an instance of each subclasses. Ask the user for an input. (Assume the user will input 3, 4, or 5 only) if the user input 3 - print the details of an object of subclass Triangle if the user input 4 - print the details of an object of subclass Square if the user input 5 - print the details of an object of subclass Pentagon SAMPLE INPUT 1. num SAMPLE OUTPUT NEEDED: Enter a number: 3 Triangle I have 3 sides My color is red

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Software Development
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT