Question: 2. Write the Java code corresponding to the following UML diagram. -x: int -y: int Rectangle + Rectangle () + Rectangle (x: int, y:int)

2. Write the Java code corresponding to the following UML diagram. -x: int -y: int Rectangle + Rectangle () + Rectangle (x: int, y:int) 

2. Write the Java code corresponding to the following UML diagram. -x: int -y: int Rectangle + Rectangle () + Rectangle (x: int, y:int) + setX (x: int) : void + getX(): int + sety (y: int) : void + getY(): int + computeArea(): int The class is called Rectangle, which contains on the following: (8 Marks) . Two instance variables x as the length and y as the width . Two constructors Setter and getter methods for x and y . The method compute Area will return the rectangle's area (x*y) Add a main method. In the main method, create two objects and print their areas using compute Area method.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!