ajout javadoc cell

This commit is contained in:
Hugo DIMITRIJEVIC 2024-03-31 08:59:14 +02:00
parent 9bc43e93c9
commit dec5d004e2

View File

@ -4,21 +4,41 @@ import androidx.annotation.NonNull;
import java.io.Serializable;
/**
* {@code Cell} is a class that represents the position of a cell in a
* two-dimensional grid.
*
* @autor Alexeï Kadir, Lyanis Souidi, Hugo Dimitrijevic
* @version 1.0
*/
public class Cell implements Serializable {
/**
* The x-coordinate of the {@code Cell}.
*/
public int x;
/**
* The y-coordinate of the {@code Cell}.
*/
public int y;
/**
* Constructs a new {@code Cell} with the specified coordinates.
*
* @param x The x-coordinate of the {@code Cell}.
* @param y The y-coordinate of the {@code Cell}.
*/
public Cell(int x, int y) {
this.x = x;
this.y = y;
}
/**
* Constructs a {@code Cell} with the same coordinates as the specified cell.
*
* @param cell The {@code Cell} to copy. If this parameter is {@code null}, the
* new {@code Cell} will have coordinates (0, 0).
*/
public Cell(Cell cell) {
if (cell == null)
return;
@ -27,13 +47,23 @@ public class Cell implements Serializable {
this.y = cell.y;
}
/**
* Calculates the hash code of the {@code Cell}.
*
* @return The hash code of the {@code Cell}.
*/
@Override
public int hashCode() {
return this.x + this.y * 31;
}
/**
* Compares the {@code Cell} with the specified object for equality.
*
* @param object The object to compare with the {@code Cell}.
* @return {@code true} if the specified object is equal to the {@code Cell},
* {@code false} otherwise.
*/
@Override
public boolean equals(Object object) {
if (object == this)
@ -46,7 +76,11 @@ public class Cell implements Serializable {
return cell.x == this.x && cell.y == this.y;
}
/**
* Returns a string representation of the {@code Cell}, in the form "[x; y]".
*
* @return A string representation of the {@code Cell}.
*/
@NonNull
@Override
public String toString() {