Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 3: [Programming] Design a class named Rectangle that extends Geometricobject. The class contains: - Two double data fields named width, and length with default

image text in transcribedimage text in transcribedimage text in transcribed

Question 3: [Programming] Design a class named Rectangle that extends Geometricobject. The class contains: - Two double data fields named width, and length with default values 1.0 to denote two sides of the rectangle. - A constructor that creates a rectangle with the specified width, and length. - The get and set methods for all two data fields. - A method named getarea() that returns the area of this rectangle. - A method named getperimeter() that returns the perimeter of this rectangle. - A method named tostring() that returns a string description for the rectangle, as follows return"Rectangle:Width="+width+"length="+length; - Your code must be fully documented. This includes using Javadoc comments. - Use the following code as a startup for your solution. You only need to implement the Rectangle class. public class Assignment1 \{ public static void main(String[] args) \{ Rectangle rectangle = new Rectangle (1,1.5); rectangle.setColor ("yellow"); rectangle.setFilled(true); System.out.println(rectangle); System.out.println ("The area is " + rectangle.getArea()); System. out.println("The perimeter is " + rectangle.getPerimeter ()); System.out.println(rectangle); \} 3 public abstract class Geometricobject \{ private String color = "white"; private boolean filled; private java.util. Date dateCreated; / Construct a default geometric object */ protected Geometricobject() i dateCreated = 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; \}

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions