Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java program 3. (40 pts) According the given Shapes class and Drawer interface, write the Java statements given in the comment line. public abstract class

java program image text in transcribed
image text in transcribed
image text in transcribed
3. (40 pts) According the given Shapes class and Drawer interface, write the Java statements given in the comment line. public abstract class Shapes extends Graphics{ public interface Drawer abstract double getArea(); void draw(); } } In addition to this, Graphics class has the following methods: drawRect(int , int y, int width, int height): Draws the outline of the specified rectangle. drawOval(int x, int y, int width, int height): Draws the outline of an oval. a. *Declare a class with name Rectangle which is subclass of Shapes and able to use method of Drawer interface b. * define two instance variables x height and width(integer)*/ c. /#define a constructor for Rectangle class such that it initializes the instance variable in part (b) d. "override the draw() method in drawer interface such that it calls the draw Rect() method inside of it." "override the get Area() method in Shapes class such that it finds the area of Rectangle object." c. Moverride the getArea() method in Shapes class such that it finds the arca of Rectangle object. } In addition to Shapes and Rectangle class, there is Circle class as follows: public class Circle extends Shapes implements Drawer double -0.0; public Circle (double r) {this.r =r;} double getArea ({ return Math.PI*r*r}; void draw({ drawOval(0, 0, (int)r, (int)r); 3 Finally, the following main routinc is called: Public class Test{ public static void main(String[] args) { Circle cl=new Circle(3.0); Shapes shapel-circlel; Drawer shapes={cl, new Rectangle(3,4)}; for(Drawer g: shapes) { g.draw();} circlel.getArea(); } } f. Give the name of polymorphic references in main program. g. Give the output of the main program. h. If I add the following lines in main program what will be the result: Shapes shaped new Shape: shape.geurean

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_2

Step: 3

blur-text-image_3

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

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions