Java Object Oriented Programming 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 shall be defined within the class having 4 color names (choose any four). Also define getArea and getPerimeter method in Shape class, both shall return 0. Create Rectangle class with length and width attributes and a Circle class with radius attribute, of type double. Properly encapsulate all fields. Circle and Rectangle shall extend Shape class and override getArea and getPerimters methods as per its type and specific formula. In Test class, create an object of Rectangle and Circle, 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 Object Oriented Programming 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 shall be defined within the class having 4 color names (choose any four). Also define getArea and getPerimeter method in Shape class, both shall return 0. Create Rectangle class with length and width attributes and a Circle class with radius attribute, of type double. Properly encapsulate all fields. Circle and Rectangle shall extend Shape class and override getArea and getPerimters methods as per its type and specific formula. In Test class, create an object of Rectangle and Circle, 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
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 11PE
Related questions
Question
100%
Java Object Oriented Programming
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 shall be defined within the class having 4 color names (choose any four).
Also define getArea and getPerimeter method in Shape class, both shall return 0. Create Rectangle class with length and width attributes and a Circle class with radius attribute, of type double. Properly encapsulate all fields.
Circle and Rectangle shall extend Shape class and override getArea and getPerimters methods as per its type and specific formula. In Test class, create an object of Rectangle and Circle, 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.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 5 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage