2 * All puzzles must inherit this class.
4 package com
.github
.puzzles
.core
;
6 public abstract class AbstractPuzzle
{
10 private Difficulty difficulty
;
12 protected AbstractPuzzle(int size
, int count
, Difficulty difficulty
) {
15 this.difficulty
= difficulty
;
18 protected AbstractPuzzle(AbstractPuzzle puzzle
) {
19 this.size
= puzzle
.size
;
20 this.counter
= puzzle
.counter
;
21 this.difficulty
= puzzle
.difficulty
;
25 * Check to see if the puzzle is correct or not.
27 * @return true if the puzzle is correct, otherwise false.
29 public abstract boolean check();
32 * Increment the counter of played times.
34 * @return the counter.
36 protected int incrementCounter() {
41 * Decrement the counter of played times.
43 * @return the counter.
45 protected int decrementCounter() {
50 * Set the counter value.
54 protected void setCounter(int counter
) {
55 this.counter
= counter
;
58 protected void reintialiseCounter() {
65 * @return the size of the puzzle.
67 public final int getSize() {
74 * @return the number of the played times.
76 public final int getCounter() {
83 * @return the difficulty of the puzzle.
85 public final Difficulty
getDifficulty() {
92 * @see java.lang.Object#hashCode()
95 public int hashCode() {
98 result
= prime
* result
+ counter
;
99 result
= prime
* result
100 + ((difficulty
== null) ?
0 : difficulty
.hashCode());
101 result
= prime
* result
+ size
;
108 * @see java.lang.Object#toString()
111 public String
toString() {
112 return "AbstractPuzzle [size=" + size
+ ", counter=" + counter
113 + ", difficulty=" + difficulty
+ "]";
119 * @see java.lang.Object#equals(java.lang.Object)
122 public boolean equals(Object obj
) {
129 if (getClass() != obj
.getClass()) {
132 AbstractPuzzle other
= (AbstractPuzzle
) obj
;
133 if (counter
!= other
.counter
) {
136 if (difficulty
!= other
.difficulty
) {
139 if (size
!= other
.size
) {