Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java class implementation Implement a Rectangle java class to create the rectangle objects and calculate the area of the rectangle objects based on the
Java class implementation Implement a Rectangle java class to create the rectangle objects and calculate the area of the rectangle objects based on the given UML class diagram. Please just implement the class and the tests in the example table will be executed automatically. ps. rectangle area = width*height -double width -double height +Rectangel() +Rectangel(double, double) +getArea():double +getWidth():double +getHeight():double +setWidth(double):void +setHeight(double):void For example: Rectangle Test Rectangle rec=new Rectangle(); System.out.println(rec.getArea()); Rectangle rec=new Rectangle (1.2,3.5); System.out.println(rec.getArea()); Rectangle rec=new Rectangle(-1.2,3.5); System.out.println(rec.getWidth()+" "+rec.getHeight()); Rectangle rec=new Rectangle(); rec.setWidth (3.5); rec.setHeight (-2.5); System.out.println(rec.getArea()); Answer: (penalty regime: 0 %) Reset answer 1 v public class Rectangle{ 2 3} //please add your code here Result 0.0 4.2 1.2 3.5 8.75
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Rectanglejava public class Rectangle private double width private double height public ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started