Compare commits
2 Commits
5eabf87c94
...
f489c4c8ab
| Author | SHA1 | Date | |
|---|---|---|---|
| f489c4c8ab | |||
| c430a1e1b0 |
@@ -1,28 +0,0 @@
|
|||||||
package network.protocol;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class PacketDispatcher {
|
|
||||||
|
|
||||||
private final List<PacketVisitor> handlers;
|
|
||||||
|
|
||||||
public PacketDispatcher() {
|
|
||||||
this.handlers = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispatch(Packet packet) {
|
|
||||||
for (PacketVisitor handler : handlers) {
|
|
||||||
handler.visitPacket(packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerHandler(PacketVisitor handler) {
|
|
||||||
handlers.add(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unregisterHandler(PacketVisitor handler) {
|
|
||||||
handlers.remove(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package network.protocol;
|
|
||||||
|
|
||||||
public class PacketFactory {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,7 @@ package sudoku.solver;
|
|||||||
|
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
|
|
||||||
|
import sudoku.structure.Coordinate;
|
||||||
import sudoku.structure.MultiDoku;
|
import sudoku.structure.MultiDoku;
|
||||||
import sudoku.structure.Sudoku;
|
import sudoku.structure.Sudoku;
|
||||||
|
|
||||||
@@ -23,9 +24,9 @@ public class StupidSolver {
|
|||||||
if (!sudoku.getCell(index).isMutable())
|
if (!sudoku.getCell(index).isMutable())
|
||||||
return solve(sudoku, index + 1);
|
return solve(sudoku, index + 1);
|
||||||
|
|
||||||
var coords = sudoku.toCoords(index);
|
Coordinate coords = sudoku.toCoords(index);
|
||||||
for (int symbol = 0; symbol < sudoku.getSize(); symbol++) {
|
for (int symbol = 0; symbol < sudoku.getSize(); symbol++) {
|
||||||
if (sudoku.tryPlaceCellSymbol(coords[0], coords[1], symbol)) {
|
if (sudoku.tryPlaceCellSymbol(coords.getX(), coords.getY(), symbol)) {
|
||||||
// on tente de placer sur la case suivante
|
// on tente de placer sur la case suivante
|
||||||
if (solve(sudoku, index + 1)) {
|
if (solve(sudoku, index + 1)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -33,7 +34,7 @@ public class StupidSolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// on a tout essayé et rien n'a fonctionné
|
// on a tout essayé et rien n'a fonctionné
|
||||||
sudoku.clearCell(coords[0], coords[1]);
|
sudoku.clearCell(coords.getX(), coords.getY());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user