Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design the class named Circle that extends the class GeometricObjects . The Circle class contains: A double data field called radius , with default values

Design the class named Circle that extends the class GeometricObjects. The Circle class contains:

A double data field called radius , with default values of 1.0, to denote the radius of the circle

A no-arg constructor that creates a default circle.

A full-arg constructor that creates a circle with the specified radius, color and filled properties.

A getter and setter method to get the instance variable radius

A method named getPerimeter() that returns the perimeter of the circle. Perimeter of the circle can be calculated as 2*radius*3.14.

A method named getArea() that returns the area of the circle. Area of the circle can be calculated as 3.14*radius*radius.

A method named toString() that returns a String description of circle as follows:

super.toString() + Circle : radius = + radius + area is : + getArea() + perimeter is : + getPerimeter();

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

CODE FOR GEOMETRIC OBJECTS:

public class GeometricObjects{

private String color;

private Boolean filled;

public GeometricObjects(){

this.color = "white";

this.filled = false;

}

/*Construct Geometric Object with specified color and filled value*/

public GeometricObjects(String color, boolean filled){

this.color = color;

this.filled = filled;

}

/* Return Color*/

public String getColor(){

return color;

}

/*Return filled. since filled is boolean we name it isFilled*/

public boolean isFilled(){

return filled;

}

/*Set new color*/

public void setColor(String color) {

this.color = color;

}

/*Set new filled*/

public void setFilled(boolean filled){

this.filled = filled;

}

/* toString method that returns the string representation of object. This method also fetches the values of color and filled--- i.e. works like a getter too*/

public String toString(){

return "Object color is: " + this.getColor() + " object filled is: " + this.isFilled() ;

}

}

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

7. Identify six intercultural communication dialectics.

Answered: 1 week ago