45.1k views
0 votes
Define the method equals for the window class . two windows will be considered equal if they are the same size and at the same position

2 Answers

4 votes

Final answer:

The method equals for the window class is defined based on the size and position of the windows.

Step-by-step explanation:

In order to define the method equals for the window class, you would need to compare the size and position of two windows. The equals method should return true if the size and position of both windows are the same, and false otherwise.

Here's an example of how the equals method could be implemented for the window class:

public class Window {
private int size;
private int position;

public Window(int size, int position) {
this.size = size;
this.position = position;
}

public boolean equals(Window other) {
if (this.size == other.size && this.position == other.position) {
return true;
}
return false;
}
}

User ICrazy
by
8.5k points
4 votes
Equating "equal" as symmetrical:

Two windows of the same size and placed in the same position is considered symmetrical. In an example where one window is placed at a certain distance from a wall and a certain distance from the floor, another window of the same size is also placed in the opposite side of the first window (based on a constant center) with the same distance from the floor and wall. The two windows can be considered equal.
User Giannis Savvidis
by
8.9k points

No related questions found