Question: Java and please fix the highlighted part in the first picture and run it again with the test codes thank you! public class Point{ private

Java and please fix the highlighted part in the first picture and run it again with the test codes thank you!

Java and please fix the highlighted part in the first picture andrun it again with the test codes thank you! public class Point{private int x; private int y; public Point(){ this.x = 0; this.y

public class Point{

private int x; private int y; public Point(){ this.x = 0; this.y = 0; } public Point(int x, int y){ this.x = x; this.y = y; } public void setX(int x){ this.x = x; } public int getX() { return this.x; } public void setY(int y){ this.y = y; } public int getY() { return this.y; } public String toString() { return "(" + x + "," + y + ")"; }

}

public static void testRectangleContains() { Shape r00 = new Rectangle(); Point p00 = new Point(); Point p23 = new Point(2,3); Shape r45 = new Rectangle(4, 5, p23);

boolean result; result = r00.contains(p00); displayResults(result, "testRectangleContains - true");

result = r00.contains(p23); displayResults(!result, "testRectangleContains - false"); // outside r45 Point p15 = new Point(1,5); Point p49 = new Point(4,9); Point p42 = new Point(4,2); Point p75 = new Point(7,5);

result = r45.contains(p15); displayResults(!result, "testRectangleContains - false"); result = r45.contains(p49); displayResults(!result, "testRectangleContains - false"); result = r45.contains(p42); displayResults(!result, "testRectangleContains - false"); result = r45.contains(p75); displayResults(!result, "testRectangleContains - false"); // inside/on r45 Point p25 = new Point(2,5); Point p48 = new Point(4,8); Point p43 = new Point(4,3); Point p65 = new Point(6,5); Point p45 = new Point(4,5); result = r45.contains(p23); displayResults(result, "testRectangleContains - true"); result = r45.contains(p25); displayResults(result, "testRectangleContains - true"); result = r45.contains(p48); displayResults(result, "testRectangleContains - true"); result = r45.contains(p43); displayResults(result, "testRectangleContains - true"); result = r45.contains(p65); displayResults(result, "testRectangleContains - true"); result = r45.contains(p45); displayResults(result, "testRectangleContains - true");

}

public static void testRectangleToString() { Shape r00 = new Rectangle(); Point p00 = new Point(); Point p23 = new Point(2,3); Shape r45 = new Rectangle(4, 5, p23); String result = r00.toString(); String expected = "Rectangle of dimensions: 0 by 0 at Point: " + p00.toString(); displayResults(result.equals(expected), "testRectangleToString"); result = r45.toString(); expected = "Rectangle of dimensions: 4 by 5 at Point: " + p23.toString(); displayResults(result.equals(expected), "testRectangleToString"); }

public static void testRectangleToString() { Shape r0o = new Rectangle(); Point poo = new Point(); Point p23 = new Point (2,3); Shape 145 = new Rectangle(4, 5, p23); String result = roo.toString(); String expected = "Rectangle of dimensions: O by O at Point: " + poo.toString(); displayResults (result.equals(expected), "testRectangleToString"); result = r45.toString(); expected = "Rectangle of dimensions: 4 by 5 at Point: " + p23.toString(); displayResults (result.equals (expected), "testRectangleToString")

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 Databases Questions!