2 * All puzzles must inherit this class.
5 package com
.github
.puzzles
.core
;
7 public abstract class AbstractPuzzle
{
10 private Difficulty difficulty
;
12 protected AbstractPuzzle(int size
, int count
, Difficulty difficulty
){
15 this.difficulty
= difficulty
;
19 * Check to see if the puzzle is correct or not.
20 * @return true if the puzzle is correct, otherwise false.
22 public abstract boolean check();
25 * Increment the counter of played times.
26 * @return the counter.
28 protected int incrementCounter(){
29 setCounter(++counter
);
34 * Decrement the counter of played times.
35 * @return the counter.
37 protected int decrementCounter(){
38 setCounter(--counter
);
43 * Set the counter value.
46 protected void setCounter(int counter
){
47 this.counter
= counter
;
52 * @return the size of the puzzle.
54 public final int getSize() {
60 * @return the number of the played times.
62 public final int getCounter() {
68 * @return the difficulty of the puzzle.
70 public final Difficulty
getDifficulty() {
75 * @see java.lang.Object#hashCode()
78 public int hashCode() {
81 result
= prime
* result
+ counter
;
82 result
= prime
* result
83 + ((difficulty
== null) ?
0 : difficulty
.hashCode());
84 result
= prime
* result
+ size
;
89 * @see java.lang.Object#equals(java.lang.Object)
92 public boolean equals(Object obj
) {
97 if (getClass() != obj
.getClass())
99 AbstractPuzzle other
= (AbstractPuzzle
) obj
;
100 if (counter
!= other
.counter
)
102 if (difficulty
!= other
.difficulty
)
104 if (size
!= other
.size
)