JAVA Implement the equals method of the Arrow class. Two arrows are equal when they have the same starting point and direction. public class Arrow { private Point start; private String direction; /** Constructs an arrow. @param x the x-position @param y the y-position @param direction a compass direction N E S W NE NW SE SW */ public Arrow(int x, int y, String direction) { start = new Point(); start.move(x, y); this.direction = direction; } /** Checks whether this arrow is equal to another. @param otherObject another arrow @return true if this arrow and otherObject have the same position and direction. */ public boolean equals(Object otherObject) { /* code goes here */ } }
JAVA
Implement the equals method of the Arrow class. Two arrows are equal when they have the same starting point and direction.
public class Arrow
{
private Point start;
private String direction;
/**
Constructs an arrow.
@param x the x-position
@param y the y-position
@param direction a compass direction N E S W NE NW SE SW
*/
public Arrow(int x, int y, String direction)
{
start = new Point();
start.move(x, y);
this.direction = direction;
}
/**
Checks whether this arrow is equal to another.
@param otherObject another arrow
@return true if this arrow and otherObject have the
same position and direction.
*/
public boolean equals(Object otherObject)
{
/* code goes here */
}
}

Trending now
This is a popular solution!
Step by step
Solved in 2 steps









