2 * Rectangular puzzles should inherit this class.
5 package com
.github
.puzzles
.core
;
7 import java
.util
.Arrays
;
9 import com
.github
.puzzles
.util
.Matrices
;
11 public abstract class AbstractRectangularPuzzle
<T
> extends AbstractPuzzle
{
17 protected AbstractRectangularPuzzle(T
[][] puzzle
, int width
, int height
, Difficulty difficulty
) {
18 super(width
* height
, 0, difficulty
);
26 * @return the width of the puzzle.
28 public final int getWidth() {
34 * @return the height of the puzzle.
36 public final int getHeight() {
42 * @return the puzzle matrix.
44 public final T
[][] getPuzzle() {
45 return Matrices
.copyOf(puzzle
);
50 * @see java.lang.Object#hashCode()
53 public int hashCode() {
55 int result
= super.hashCode();
56 result
= prime
* result
+ height
;
57 result
= prime
* result
+ Arrays
.hashCode(puzzle
);
58 result
= prime
* result
+ width
;
63 * @see java.lang.Object#equals(java.lang.Object)
66 public boolean equals(Object obj
) {
69 if (!super.equals(obj
))
71 if (getClass() != obj
.getClass())
73 AbstractRectangularPuzzle other
= (AbstractRectangularPuzzle
) obj
;
74 if (height
!= other
.height
)
76 if (!Arrays
.deepEquals(puzzle
, other
.puzzle
))
78 if (width
!= other
.width
)