Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a test program to get areas and perimeters of both circle and rectangle objects in the previous example. There is no sample test case

Write a test program to get areas and perimeters of both circle and rectangle objects in the previous example. image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
There is no sample test case
GeometricObject.java public abstract class GeometricObject private String color "White" private boolean filled private java.util.Date dateCreated; * Construct a default geometric object * protected GeometricObject date Created = new java.util.Date(): } *** Construct a geometric object with color and filled value protected GeometricObject(String color, boolean filled) dateCreated = new java.util.Date(); this.color-color: this filled - filled > **Return color public String getColor return color; 1 *** Set a new color public void setColor(String color) this.color=color; > **Return filled. Since filled is boolean, the get method is named isFilled public boolean isFilled : return filled; *** Return width public double getWidth retumn width: 1 /** Set a new width public void setWidth(double width) { this.width = width: /**Return height public double getHeight() return height: > /** Set a new height public void setHeight(double height) this.height = height: 1 @Override /** Return area public double getArea) return width" height: @Override /** Return perimeter/ public double getPerimeter) return 2 (width + height: Circle.java ublic class Circle extends GeometricObject private double radius public Circle 1 public Circle double radius) this radius -radius: 1 /** Rctum radius public double getRadiuso) return radius: ** Set a new radius public void setRadius(double radius) this.radius -radius: 1 @Override /** Return arca public double getAreal return radius radius. Math.PI; **Return diameter public double getDiameter() { return 2* radius @Override /** Return perimeter public double getPerimeter retum 2* radius * Math.PI: 1 /* Print the circle info public void printCircle System.out.println("The circle is created * + getDateCreatedo + System.out.println("The circle is created " + getDateCreated() + "and the radius is " + radius); } }

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

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions

Question

=+8. Be sure you considered consumer benefits.

Answered: 1 week ago