Create a Shape class that shall have color and filled instance variables of enum Color and boolean type. The filled boolean variable shall show, whether the shape is filled (colored). The enum Color...


Create aShape class that shall havecolorandfilledinstance variables ofenum Colorandbooleantype. The filled boolean variable shall show, whether the shape is filled (colored). The enumColorshall be defined within the class having 4 color names (choose any four).


Also definegetAreaandgetPerimetermethod inShapeclass, both shall return 0. CreateRectangleclass withlengthandwidthattributes and aCircleclass withradiusattribute, of typedouble. Properly encapsulate all fields.





Circle andRectangle shall extendShapeclass and overridegetAreaandgetPerimtersmethods as per its type and specific formula. InTestclass, create an object ofRectangleandCircle, by initializing all attributes in constructor and print both shapes' area and perimters.


In Test class, define a static method with following signature,


public static void printEachShapeCount(Shape... shapes)

As you know, the parent type variable can hold the reference of any child class object. That means, we can call above method by passing any number of Circle and Rectangle objects. Define the method body, such that, it shall print how many circles and how many rectangles were passed to this method in variable length argument.

(Java)


Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here