Question
Problem Description: Create an abstract class called Shape to store information about a shape. Each shape contains the figure type and a method to calculate
Problem Description:
Create an abstract class called Shape to store information about a shape. Each shape contains the figure type and a method to calculate the area. Create sub-classes of Shape called Square and Circle. Note: That radius, sides, and areas can be decimals.
Files
ShapeMain.java
Shape.java
Square.java
Circle.java
Shape Main Class
Use the main class for testing. You won't be graded on your main class other than it must exist.
Shape Class
Build the Shape class with the following specifications:
Must be abstract
Public abstract getArea()
Square Class
Build the Square class with the following specifications:
Subclass of Shape
Public setSide()
Public getSide()
Implements getArea() correctly
Ex: Using setSide(5) results in getArea() return 10. Area = side*side
Circle Class
Build the Circle class with the following specifications:
Subclass of Shape
Public setRadius()
Public getRadius()
Implements getArea() correctly
Ex: Using setRadius(5) results in getArea() return 10. Area = PI*(R^2). Hint use Math.PI
Deliverables:
Square.java
Shape.java
ShapeMain.java
Circle.java
You must submit these file(s)
Compile command
javac Square.java Shape.java ShapeMain.java Circle.java -Xlint:all -encoding utf-8
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