Question: Create a Java project named Proj9. In this project do the following: 1. Create an Interface named as Colorable o This interface contains two methods:
Create a Java project named Proj9. In this project do the following: 1. Create an Interface named as Colorable o This interface contains two methods: getArea(), which returns a double howTo Color(), which returns a string 2. Create a class named Circle that implements the Colorable interface. Circle class has an Integer data field named radius 3. Create a class named Rectangle that implements the Colorable interface. Rectangle class has a two double data fields named width, height 4. For Circle objects, the getArea() method calculates and returns the area of the circle according to the formula (c_area= PI* radius^2) 5. For Rectangle objects, the getArea() method calculates and returns the area of the rectangle according to the formula (r_area= width*height) 6. For Circle objects, the howToColor() method returns a String that colors the Circle according to its area Hint: using the getArea() method. If the area of the circle is greater than 50, the return color will be Red, else the color will be Yellow. 7. For Rectangle objects, the howToColor() method returns a String that colors the Circle according to the width and the height of the rectangle. If the width is greater than 50, the return color will be Black, else the color will be White. 8. Create a Main class named Test. o In the Test class, define the method printObject(Colorable) that takes a array of type Colorable as an argument and prints out: The index of the object Its class name Its area Its color o In the main() method, do the following: Create a array of Colorable with size=2; Create a Circle object with a radius specified by the user. Create a Rectangle object with a width and a height specified by the user. Fill the array with the created objects Write a suitable call to the method printObjects(Colorable []) to print information about the create objects.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
