Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago