Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question #1 The java.awt.Rectangle class of the standard Java library does not supply methods for computing the area and the perimeter of a rectangle. Create
Question #1 The java.awt.Rectangle class of the standard Java library does not supply methods for computing the area and the perimeter of a rectangle. Create a subclass BetterRectangle of the Rectangle class that has getPerimeter and getArea methods. Do not add any instance variables to the BetterRectagle class. In its constructor, call the setLocation and setSize methods of the Rectangle class. Create a tester class (BetterRectangleTester) with a main method that tests the methods of BetterRectangle. BetterRectangleTester must have at least 3 test cases with input and expected output. Make sure that your code compiles and runs without errors when the following commands are used For compilation javac BetterRectangleTester.java BetterRectangle.java For execution: java BetterRectangleTester [15 points] Question #2 A labeled point has x- and y-coordinates and a string label. Create a class LabeledPoint with a constructor LabeledPoint (int x, int y, string label) and a toString method that returns x, y, and the label. The class LabeledPoint must extend the Java AWT class (java.awt.Point). The toString method of LabeledPoint should invoke the toString method of the Point class. Also, the constructor of LabeledPoint should invoke a constructor from the Point class. Create a tester lass (LabeledPointTester) with a main method that tests the toString method of LabeledPoint LabeledPointTester must have at least 3 test cases with input and expected output. Make sure that your code compiles and runs without errors when the following commands are used For compilation javac LabeledPointTester.java LabeledPoint.java For execution java LabeledPointTester
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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