Write a rectangle class with a method named contains


Problem

Write a Rectangle class (Rectangle.java) with a method named "contains" that accepts a point (x, y) and returns true if the point occurs within a rectangle, false otherwise. Do not use the features of the java.awt.geom package.

Coordinates must be double.

Use standard coordinate system (moving from left to right x is increasing and from up to down y is decreasing).

Your rectangle class should have 2 coordinates defined for two opposite corners (x1,y1,x2,y2) as instance variables (x1,y1 is for bottom left corner and x2,y2 is for top right corner).

Your Rectangle class should have a main method. Inside the main method create two rectangles and a testing point for each rectangle with the following coordinates (x,y):

Rectangle1 (0,0), (2,4) and testing point (1,1).
Rectangle2 (0,0), (3,5) and testing point (4,5).

Your code must run without any errors and it should print out the following output by using "contains method":

Testing point (1,1) is inside of Rectangle1 (0.0,0.0), (2.0,4.0)
Testing point (4,5) is outside of Rectangle2 (0.0,0.0), (3.0,5.0)

If the code does not compile, no points is given. If your contains method has a logic error you will get zero points. If you did not define the rectangle class correctly (it must have 4 instance variables, a constructor, a "contains" method, and a "main" method), you will also get zero points. Your main method must print out the example output given above or you will get no points.

After testing your code in NetBeans, paste your Rectangle.java code to here. Remember that your Rectangle.java code must compile as it is without any modification.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a rectangle class with a method named contains
Reference No:- TGS03277198

Expected delivery within 24 Hours