Question: Program # 2 - Geometric Shapes For this exercise you will need to make 4 class files. ( Main ) Shape . java, Circle.java, Square.java,

Program #2- Geometric Shapes
For this exercise you will need to make 4 class files. (Main)Shape.java, Circle.java, Square.java, and Rectangle.java
(A) Add these features to the Circle.java class from the lecture examples:
Make the 'color' attribute private
Make a constructor with two attributes for assigning a value to radius and color when the Circle is instantiated.
add any missing setters or getters for the radius and color attributes.
Add method that returns the area of the shape
(B) Add a class named Square.java
Give it private attributes double side and String color
Make a constructor with two attributes for assigning a value to side and color when the Square is instantiated.
Add getter and setter methods for all of the attributes.
Add a method that returns the area of the shape.
(C) Make the Rectangle.java class.
Also,
Add a color attribute and make it private.
Make a constructor with three attributes for assigning a value to width, height, and color when the Rectangle is instantiated.
Add getter and setter methods for all of the attributes.
Add a method that returns the area of the shape.
(D) Have the main method do the following:
Instantiate two instances of the Circle class with different radius's and colors.
Instantiate two instances of the Square class with different sides's and colors.
Instantiate two instances of the Rectangle class with different sides's and colors.
Have the program display all of the available values for each of these 6 objects, including their areas.
====================================================================
Please zip your ENTIRE PROJECT. If it doesn't compile(run) meaning there are errors in your code that you didn't fix you will get a 0.
Even if you didn't finish or get stuck, make sure it runs with no errors.

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 Programming Questions!