Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a project named Proj8. In this project, do the following: 1. Create a class named Colorable. 2. Create a class named Circle that extends

image text in transcribed
image text in transcribed
Create a project named Proj8. In this project, do the following: 1. Create a class named Colorable. 2. Create a class named Circle that extends the Colorable class. - In the Circle class, declare a private double data field named radius. 3. Create a class named Rectangle that extends the Colorable class. - In the Rectangle class, declare two private double data fields named widthand height. 4. The Colorable class contains an abstract method getArea() that returns a double area. 5. In the Circle class, implement the method getArea() to calculate the area of a circle. "Hint: area= P1* radius "radius". 6. In the Rectangle class, implement the method getArea() to calculate the area of a Rectangle. "Hint: area "width* height" 7. In the main method - Create a Circle object with a radius specified by the user. - Print the area of the created circle. - Create a Rectangle object with a width and a height specified by the user. - Print the area of the created rectangle. 9. Modify the Colorable class, by implementing the method howToColor(Colorable). This method takes a Colorable object as an argument and returns a string that describe the color of that object; it returns "Red" for Circle objects, and "Yellow" for Rectangle objects. (Hint: use the instanceof operator). Create a Java project named Proj9. In this project do the following: 1. Create an Interface named as Colorable ,this interface contains two methods 2. Create a class named Circle that implements the Colorable interfce. - 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 circleaccording to the formula (c_area =Pl radius 2 ). 5. For Rectangle objects, the getArea() method calculates and returns the area of therectangle according to the formula ( rarea = 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 rectangle according to the width the rectangle. If the width is greater than 50 , the returned color will be"Black", else the color will be "White

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions

Question

1. How might volunteering help the employer and the employee?

Answered: 1 week ago