Question: You will need 4 classes. The first class is the Main.Java, the second class is the Shape.java, the third class is Circle.java, and lastly the

You will need 4 classes. The first class is the Main.Java, the second class is the Shape.java, the third class is Circle.java, and lastly the fourth class is the Rectangle.java.

Shape.java will be the super class that Circle.java, and Rectangle.java will inherent from.

Main.java will simply house your main method (where all your output will come out of, and where all objects will be instantiated).

Shape:

Fields: String color; //this is the color of the shape, which is inherited Boolean filled; //this means the shape is either filled or not filled, this is inherited.

Methods: getColor(){ return color; } getFilled(){ return filledOrNot; }

Circle:

Fields: Float radius; Constructors: Default circle constructor. Circle constructor with all the parameters, including inherited parameters (hint: we use super to achieve this).

Methods: getRadius(){}

Rectangle:

Fields: double width; double length;

Constructors: Default rectangle constructor.

Rectangle constructor with all the parameters included inherited parameters (hint: we use super to achieve this).

Main: From within your Main Class, where your main method is supposed to be, instantiate an object of type Circle and of type Rectangle, and output the color, whether is filled out or not, as well as the radius for the circle, and the length and width of the rectangle (respectively)

Remember encapsulation means that certain fields will be private, and only accessible to other classes through constructors, getters, and setters. You will be graded on your ability to apply this.

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!