Write a complete class definition for a class named Point I
) Write a complete class definition for a class named Point. It will represent a standard Cartesian point consisting of an x and y coordinate. These two coordinates should be created as private or protected integer variables in the class. The class should also have the following public member functions defined.
Point( int a, int b) - a constructor function that initializes the variable x to the value passed to the function inside parameter a, and initializes the data member y to the value passed to the function inside parameter b.
int getx( ) - simple public function that returns the value stored in the data member x.
int gety( ) - simple public function that returns the value stored in the data member y.
void setx( int a ) -stores the value passed inside of parameter a into the data member x.
void sety( int b ) -stores the value passed inside of parameter b into the data member y.
void setxy(int a, int b) – stores the given value a into the x coordinate and the given argument b into the y coordinate BUT only if they are both greater than 0.
boolean isEqual( Point otherPoint) – returns true if this point equals the otherPoint passed in as an argument. We will consider two points equal if they have the same x and y value.
(using java language)
Solution
Point.java
public class Point {
 protected int x, y; // coordinates of Point
 // constructor
 public Point( int xCoordinate, int yCoordinate )
 {
    x = xCoordinate;
    y = yCoordinate;
 }
// set x and y coordinates of Point
 public void setXY( int xCoordinate, int yCoordinate )
 {
    if(xCoordinate>0 && yCoordinate > 0){
 x = xCoordinate;
 y = yCoordinate;
    }
 }
// get x coordinate
 public int getX()
 {
 return x;
 }
public void setX(int x) {
    this.x = x;
 }
public void setY(int y) {
    this.y = y;
 }
// get y coordinate
 public int getY()
 {
 return y;
 }
boolean isEqual( Point otherPoint) {
    if(otherPoint.x == x && otherPoint.y == y){
        return true;
    }
    return false;
 }
}


