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) + 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
Get step-by-step solutions from verified subject matter experts
