Write a Java program that defines a Shape class having an abstract method draw(). Inherit Rectangle, Triangle, and Square classes from Shape and provide definition of the abstract method. Write a Driver class that receives type of the shape as input from the user and creates an object of the required class through polymorphism. Then the draw() method of required shape is invoked that further receives inputs from the user depending upon the type of the shape. For example to draw a square just one side length is required, for rectangle two sides are required and for triangle only one length of 90 degree side is required. Then for each draw() implementation, filled shape of asterisks (*) should be drawn on console. Give the screen shots of output...and the program title is named as "Mubeen Aslam 18-ARID-2666"
Write a Java program that defines a Shape class having an abstract method draw(). Inherit Rectangle, Triangle, and Square classes from Shape and provide definition of the abstract method. Write a Driver class that receives type of the shape as input from the user and creates an object of the required class through polymorphism. Then the draw() method of required shape is invoked that further receives inputs from the user depending upon the type of the shape. For example to draw a square just one side length is required, for rectangle two sides are required and for triangle only one length of 90 degree side is required. Then for each draw() implementation, filled shape of asterisks (*) should be drawn on console.
Give the screen shots of output...and the program title is named as "Mubeen Aslam 18-ARID-2666"
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 6 images