Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The first class is the Shape class, which is an abstract class that extends the predefined Java class Rectangle. It should contain two instance variables,

The first class is the Shape class, which is an abstract class that extends the predefined Java class Rectangle. It should contain two instance variables, the color of the shape and whether the shape is solid or hollow. It should also contain a class (static) variable that keeps track of how many shapes have been created.. It should have three instance methods, one class method and one abstract method:

1. A constructor that accepts three parameters for the purpose of initializing the characteristics of the shape, a Rectangle object that defines the dimensions and position of the shape, the color of the shape and whether the shape is solid or hollow. It should also update the number of shapes created so far.

2. An instance method named setColor that accepts the Graphics object as a parameter and sets the color for the next draw operation to the color of the current shape.

3. An instance method named getSolid that returns whether the shape is solid or hollow.

4. A class method named getNoOfShapes that returns the number of shapes created so far.

5. An abstract method named draw that accepts a Graphics object as a parameter.

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

More Books

Students also viewed these Databases questions