Question: Create four files to submit: GeometricShape .java Base Class definition Circle.java Derived Class definition Square.java-Derived Class definition ClientClass.java - Contains main() method (1) Build the

Create four files to submit:

GeometricShape .java Base Class definition

Circle.java Derived Class definition

Square.java-Derived Class definition

ClientClass.java - Contains main() method

(1) Build the following three classes with the following specifications:

A) GeometricShape Class (a base class)

Private fields String name - Initialized in default constructor to "none" String color - Initialized in default constructor to "none" -Constructors (2 pts) Default constructor constructor with parameters: GeometricShape(String name, String color)

Public member methods (mutators & accessors) setName(String name) & getName() (2 pts) setColor(String color) & getColor() (2 pts)

B) Circle Class (a derived class of GeometricShape)

Private field: double radius - Initialized in default constructor to 1.0 -Constructors (2 pts) Default constructor constructor with parameters: Circle(String name, String color, double radius)

Public member methods (mutators & accessors) setRadius(double radius) & getRadius() (2 pts) getArea() (2 pts)

C) Square Class (a derived class of GeometricShape)

Private field: double side - Initialized in default constructor to 1.0 -Constructors (2 pts) Default constructor constructor with parameters: Square(String name, String color, double side)

Public member methods (mutators & accessors) setSide(double side) & getSide() (2 pts) getArea() (2 pts)

(2) In main(), prompt the user for two names, two color, one radius and one side; then create one object of Circle class and one object of Square class. (1 pts) Ex:

Creating an Object of the Circle class Enter the name and color: myCircle red Enter the radius: 3 Creating an Object of the Square class Enter the name and color: yourSquare black Enter the radius: 2.5 

(3) Output the areas of the shapes (format to 2 decimal place) (3 pts) Ex:

The info for the Circle object: name: myCircle, color: red, radius: 3.00, and the area: 28.27 The info for the Square object: name: yourSquare, color: black, radius: 2.50, and the area: 6.25 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!