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
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