Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question Goal: Apply ideas about inheritance with Abstract classes Assignment: Imagine that you are a mathematician that is creating a program to automatically generate shape
Question
Goal: Apply ideas about inheritance with Abstract classes
Assignment: Imagine that you are a mathematician that is creating a program to automatically generate shape objects. The concept of a shape means nothing on its own but begins to take shape ;) when you define its boundaries.
The Abstract class Shape has already been created for you. Shape defines the abstract method calculateArea and the concrete method displayShape which prints "This is a shape.".
Create two classes, Circle and Rectangle that meet the following requirements:
They can be instantiated
They have constructor methods that define the minimum properties for calculating the shape's area eg you only need a circle's radius to calculate its area These should be integers.
They redefine the calculateArea method to calculate and return that shape's area.
They override the displayShape method to display "This is a
Abstract class Shape, serving as a blueprint for various shapes
abstract class Shape
Abstract method to calculate the area, must be implemented by subclasses
public abstract double calculateArea;
A concrete method to display the type of shape
public void displayShape
System.out.printlnThis is a shape.";
Write your code here. Please explain as well. Thank you!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started