From 7f4f9408cb3b8b73b7e2ba83b318e1d3bf84aa41 Mon Sep 17 00:00:00 2001 From: Patrick Azevedo Date: Wed, 18 Oct 2023 09:00:26 -0300 Subject: [PATCH 1/2] Criado o projeto --- .../src/main/java/facade/Controller.java | 41 ------ jogo-oito/src/main/java/interfaces/Edge.java | 19 --- jogo-oito/src/main/java/interfaces/Graph.java | 28 ---- .../src/main/java/interfaces/Vertex.java | 36 ------ jogo-oito/src/main/java/model/Adjacent.java | 40 ------ jogo-oito/src/main/java/model/Cell.java | 109 ---------------- jogo-oito/src/main/java/model/Keyboard.java | 38 ------ jogo-oito/src/main/java/model/Matrix.java | 39 +++--- jogo-oito/src/main/java/util/Board.java | 94 -------------- jogo-oito/src/main/java/view/JogoDosOito.java | 22 ++-- .../src/test/java/game/AdjacentTest.java | 39 ------ jogo-oito/src/test/java/game/BoardTest.java | 102 +++++++-------- jogo-oito/src/test/java/game/CellTest.java | 122 ------------------ 13 files changed, 79 insertions(+), 650 deletions(-) delete mode 100644 jogo-oito/src/main/java/facade/Controller.java delete mode 100644 jogo-oito/src/main/java/interfaces/Edge.java delete mode 100644 jogo-oito/src/main/java/interfaces/Graph.java delete mode 100644 jogo-oito/src/main/java/interfaces/Vertex.java delete mode 100644 jogo-oito/src/main/java/model/Adjacent.java delete mode 100644 jogo-oito/src/main/java/model/Cell.java delete mode 100644 jogo-oito/src/main/java/model/Keyboard.java delete mode 100644 jogo-oito/src/main/java/util/Board.java delete mode 100644 jogo-oito/src/test/java/game/AdjacentTest.java delete mode 100644 jogo-oito/src/test/java/game/CellTest.java diff --git a/jogo-oito/src/main/java/facade/Controller.java b/jogo-oito/src/main/java/facade/Controller.java deleted file mode 100644 index 28c6df1b..00000000 --- a/jogo-oito/src/main/java/facade/Controller.java +++ /dev/null @@ -1,41 +0,0 @@ -package facade; - -import interfaces.Graph; -import interfaces.Vertex; -import java.util.List; -import util.Board; - -public class Controller { - - private final Graph board; - - public Controller() { - this.board = new Board(); - } - - public void feedback() { - this.board.feedback(); - } - - public void setting() { - this.board.setting(); - } - - public List getCells() { - return this.board.getCells(); - } - - public void swap(Integer keyCode) { - this.board.swap(keyCode); - } - - public Boolean checkGameOver() { - return this.board.checkGameOver(); - - } - - public void click(Integer cellValue) { - this.board.click(cellValue); - } - -} diff --git a/jogo-oito/src/main/java/interfaces/Edge.java b/jogo-oito/src/main/java/interfaces/Edge.java deleted file mode 100644 index 20e56cd0..00000000 --- a/jogo-oito/src/main/java/interfaces/Edge.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template - */ -package interfaces; - -import model.Keyboard; - -/** - * - * @author allen - */ -public interface Edge { - - Keyboard getKey(); - - Vertex getCell(); - -} diff --git a/jogo-oito/src/main/java/interfaces/Graph.java b/jogo-oito/src/main/java/interfaces/Graph.java deleted file mode 100644 index e22aad8e..00000000 --- a/jogo-oito/src/main/java/interfaces/Graph.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template - */ -package interfaces; - -import java.util.List; - -/** - * - * @author allen - */ -public interface Graph { - - void feedback(); - - void setting(); - - void swap(Integer keyCode); - - List getCells(); - - Vertex getEmptyCell(); - - void click(Integer cellValue); - - Boolean checkGameOver(); -} diff --git a/jogo-oito/src/main/java/interfaces/Vertex.java b/jogo-oito/src/main/java/interfaces/Vertex.java deleted file mode 100644 index 4ff55e4b..00000000 --- a/jogo-oito/src/main/java/interfaces/Vertex.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template - */ -package interfaces; - -import java.util.List; -import model.Keyboard; - -/** - * - * @author allen - */ -public interface Vertex { - - void setValue(Integer value); - - Integer getValue(); - - void creatingHorizontalAdjacent(Vertex cell); - - void creatingVerticalAdjacent(Vertex cell); - - String valueToText(); - - Edge getAdjacentByKeyCode(Keyboard key); - - Vertex click(Keyboard key); - - List getAdjacents(); - - void addAdjacents(Edge edge); - - Vertex swapCells(Integer value); - -} diff --git a/jogo-oito/src/main/java/model/Adjacent.java b/jogo-oito/src/main/java/model/Adjacent.java deleted file mode 100644 index 6573c4f4..00000000 --- a/jogo-oito/src/main/java/model/Adjacent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template - */ -package model; - -import interfaces.Edge; -import interfaces.Vertex; -import java.util.Objects; - -/** - * - * @author allen - */ -public class Adjacent implements Edge{ - - private final Keyboard key; - private final Vertex cell; - - public Adjacent(Keyboard key, Vertex cell) { - this.key = key; - this.cell = cell; - } - - @Override - public Keyboard getKey() { - return this.key; - } - - @Override - public Vertex getCell() { - return this.cell; - } - - @Override - public boolean equals(Object obj) { - return Objects.equals(((Adjacent) obj).getKey(), this.getKey()); - } - -} diff --git a/jogo-oito/src/main/java/model/Cell.java b/jogo-oito/src/main/java/model/Cell.java deleted file mode 100644 index 744d8d39..00000000 --- a/jogo-oito/src/main/java/model/Cell.java +++ /dev/null @@ -1,109 +0,0 @@ -package model; - -import interfaces.Edge; -import interfaces.Vertex; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -public class Cell implements Vertex { - - private Integer value; - private final List adjacents; - public static Integer content; - - public Cell(Integer value) { - this.value = value; - this.adjacents = new ArrayList<>(); - } - - public Cell() { - this.value = Cell.content++; - this.adjacents = new ArrayList<>(); - } - - @Override - public void setValue(Integer value) { - this.value = value; - } - - @Override - public Integer getValue() { - return this.value; - } - - @Override - public void creatingHorizontalAdjacent(Vertex cell) { - this.adjacents.add(new Adjacent(Keyboard.LEFT, cell)); - cell.getAdjacents().add(new Adjacent(Keyboard.RIGHT, this)); - } - - @Override - public void creatingVerticalAdjacent(Vertex cell) { - this.adjacents.add(new Adjacent(Keyboard.UP, cell)); - cell.getAdjacents().add(new Adjacent(Keyboard.DOWN, this)); - } - - @Override - public String valueToText() { - return Optional.of(this.value) - .filter(value -> value != 0) - .map(String::valueOf) - .orElse(""); - } - - @Override - public Edge getAdjacentByKeyCode(Keyboard key) { - Adjacent edge = new Adjacent(key, null); - Integer indexEdge = this.adjacents.indexOf(edge); - return Optional.of(indexEdge) - .filter(index -> index != -1) - .map(this.adjacents::get) - .orElse(null); - } - - @Override - public Vertex click(Keyboard key) { - Edge adjacent = this.getAdjacentByKeyCode(key); - return this.movement(adjacent); - } - - private Vertex movement(Edge adjacent) { - return Optional.ofNullable(adjacent) - .map(Edge::getCell) - .map(this::swapCells) - .orElse(this); - } - - private Vertex swapCells(Vertex movementCell) { - this.setValue(movementCell.getValue()); - movementCell.setValue(0); - return movementCell; - } - - @Override - public Vertex swapCells(Integer value) { - return this.adjacents.stream() - .filter(adjacent -> Objects.equals(adjacent.getCell().getValue(), value)) - .findFirst() - .map(this::movement) - .orElse(this); - } - - @Override - public List getAdjacents() { - return this.adjacents; - } - - @Override - public void addAdjacents(Edge edge) { - this.adjacents.add(edge); - } - - @Override - public boolean equals(Object obj) { - return Objects.equals(this.value, ((Cell) obj).value); - } - -} diff --git a/jogo-oito/src/main/java/model/Keyboard.java b/jogo-oito/src/main/java/model/Keyboard.java deleted file mode 100644 index ada8bb7a..00000000 --- a/jogo-oito/src/main/java/model/Keyboard.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template - */ -package model; - -import java.awt.event.KeyEvent; -import java.util.Arrays; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; - -public enum Keyboard { - - UP(KeyEvent.VK_UP), - DOWN(KeyEvent.VK_DOWN), - LEFT(KeyEvent.VK_LEFT), - RIGHT(KeyEvent.VK_RIGHT); - - private final Integer value; - - private static final Map map = Arrays.stream(Keyboard.values()) - .collect(Collectors.toMap(Keyboard::getValue, Function.identity())); - - - Keyboard(Integer value) { - this.value = value; - } - - public Integer getValue() { - return value; - } - - public static Keyboard fromValue(Integer value) { - return map.get(value); - } - -} diff --git a/jogo-oito/src/main/java/model/Matrix.java b/jogo-oito/src/main/java/model/Matrix.java index 29586eaa..0745f371 100644 --- a/jogo-oito/src/main/java/model/Matrix.java +++ b/jogo-oito/src/main/java/model/Matrix.java @@ -4,7 +4,8 @@ */ package model; -import interfaces.Vertex; +import service.CellImpl; +import service.interfaces.Cell; import java.util.ArrayList; import java.util.List; @@ -17,12 +18,12 @@ public final class Matrix { private final Row firstRow; private final Row secondRow; private final Row thirdRow; - public static List cells; + public static List cells; public Matrix() { Matrix.cells = new ArrayList<>(); - Cell.content = 1; + CellImpl.content = 1; this.firstRow = new Row(); this.secondRow = new Row(); this.thirdRow = new Row(); @@ -30,14 +31,14 @@ public Matrix() { } private void defineAdjacent() { - this.firstRow.initial.creatingVerticalAdjacent(secondRow.initial); - this.secondRow.initial.creatingVerticalAdjacent(thirdRow.initial); + this.firstRow.initial.createVerticalAdjacent(secondRow.initial); + this.secondRow.initial.createVerticalAdjacent(thirdRow.initial); - this.firstRow.center.creatingVerticalAdjacent(secondRow.center); - this.secondRow.center.creatingVerticalAdjacent(thirdRow.center); + this.firstRow.center.createVerticalAdjacent(secondRow.center); + this.secondRow.center.createVerticalAdjacent(thirdRow.center); - this.firstRow.last.creatingVerticalAdjacent(secondRow.last); - this.secondRow.last.creatingVerticalAdjacent(thirdRow.last); + this.firstRow.last.createVerticalAdjacent(secondRow.last); + this.secondRow.last.createVerticalAdjacent(thirdRow.last); this.changePositionToValidateTemplate(); } @@ -47,20 +48,20 @@ private void changePositionToValidateTemplate(){ } - public List getCells() { + public List getCells() { return Matrix.cells; } - private final class Row { + private static final class Row { - public final Cell initial; - public final Cell center; - public final Cell last; + public final CellImpl initial; + public final CellImpl center; + public final CellImpl last; public Row() { - this.initial = new Cell(); - this.center = new Cell(); - this.last = new Cell(); + this.initial = new CellImpl(); + this.center = new CellImpl(); + this.last = new CellImpl(); this.defineAdjacent(); this.loadCells(); } @@ -72,8 +73,8 @@ public void loadCells() { } public void defineAdjacent() { - this.initial.creatingHorizontalAdjacent(this.center); - this.center.creatingHorizontalAdjacent(this.last); + this.initial.createHorizontalAdjacent(this.center); + this.center.createHorizontalAdjacent(this.last); } } diff --git a/jogo-oito/src/main/java/util/Board.java b/jogo-oito/src/main/java/util/Board.java deleted file mode 100644 index e71e83ea..00000000 --- a/jogo-oito/src/main/java/util/Board.java +++ /dev/null @@ -1,94 +0,0 @@ -package util; - -import interfaces.Graph; -import interfaces.Vertex; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Optional; -import java.util.stream.IntStream; -import model.Keyboard; -import model.Matrix; - -public class Board implements Graph { - - private List cells; - private Vertex emptyCell; - private Integer length; - private Matrix matrix; - - public Board() { - } - - @Override - public void feedback() { - this.matrix = new Matrix(); - this.cells = this.matrix.getCells(); - this.length = cells.size(); - this.defineEmptyCell(); - } - - @Override - public void setting() { - this.matrix = new Matrix(); - this.cells = this.matrix.getCells(); - this.length = cells.size(); - this.shuffleCell(); - this.defineEmptyCell(); - - } - - private void shuffleCell() { - Iterator iterator = this.shuffleValues().iterator(); - this.cells.stream() - .forEach(vertex -> vertex.setValue(iterator.next())); - } - - private List shuffleValues() { - List values = new ArrayList<>(); - this.cells.stream() - .map(Vertex::getValue) - .forEach(values::add); - Collections.shuffle(values); - return values; - } - - private void defineEmptyCell() { - Optional minCell = this.cells.stream() - .min(Comparator.comparing(cell -> cell.getValue())); - minCell.ifPresent(cell -> { - this.emptyCell = cell; - }); - } - - @Override - public void click(Integer cellValue) { - this.emptyCell = this.emptyCell.swapCells(cellValue); - } - - @Override - public void swap(Integer keyCode) { - Keyboard key = Keyboard.fromValue(keyCode); - this.emptyCell = this.emptyCell.click(key); - } - - @Override - public List getCells() { - return this.cells; - } - - @Override - public Vertex getEmptyCell() { - return this.emptyCell; - } - - @Override - public Boolean checkGameOver() { - return IntStream.range(0, this.length) - .allMatch(index -> this.cells.get(index).getValue() == (index + 1) % this.length); - - } - -} diff --git a/jogo-oito/src/main/java/view/JogoDosOito.java b/jogo-oito/src/main/java/view/JogoDosOito.java index 2b687559..4b6b7dc4 100644 --- a/jogo-oito/src/main/java/view/JogoDosOito.java +++ b/jogo-oito/src/main/java/view/JogoDosOito.java @@ -1,7 +1,7 @@ package view; -import facade.Controller; -import interfaces.Vertex; +import controller.Controller; +import service.interfaces.Cell; import java.awt.Font; import java.awt.GridLayout; import java.awt.event.ActionEvent; @@ -21,13 +21,11 @@ public class JogoDosOito extends JFrame implements KeyListener { private final List buttons; private final Controller controller; - private JButton reset; - private JButton feedback; public JogoDosOito() { super("Jogo dos Oito"); this.controller = new Controller(); - this.controller.setting(); + this.controller.setter(); this.buttons = new ArrayList<>(); } @@ -54,7 +52,7 @@ private Integer textToValue(String text) { .orElse(0); } - private JButton configButton(Vertex cell) { + private JButton configButton(Cell cell) { JButton button = new JButton(); button.setFont(new Font("Arial", Font.BOLD, 36)); button.setText(cell.valueToText()); @@ -78,10 +76,10 @@ private void checkGameOver() { } private void configMenu() { - this.reset = this.configReset(); - this.feedback = this.configFeedback(); - add(this.feedback); - add(this.reset); + JButton reset = this.configReset(); + JButton feedback = this.configFeedback(); + add(feedback); + add(reset); add(new JLabel("")); } @@ -105,7 +103,7 @@ private JButton configFeedback() { private void resetGame() { - this.controller.setting(); + this.controller.setter(); this.updateBoard(); } @@ -115,7 +113,7 @@ private void showFeedback() { } private void updateBoard() { - List cells = this.controller.getCells(); + List cells = this.controller.getCells(); IntStream.range(0, cells.size()) .forEach(index -> { JButton button = this.buttons.get(index); diff --git a/jogo-oito/src/test/java/game/AdjacentTest.java b/jogo-oito/src/test/java/game/AdjacentTest.java deleted file mode 100644 index 49dd2ac3..00000000 --- a/jogo-oito/src/test/java/game/AdjacentTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package game; - -import model.Adjacent; -import model.Cell; -import model.Keyboard; -import interfaces.Edge; -import interfaces.Vertex; -import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; - -public class AdjacentTest { - - @Test - public void testGetKey() { - Edge edge = new Adjacent(Keyboard.RIGHT, null); - assertEquals(Keyboard.RIGHT, edge.getKey()); - } - - @Test - public void testGetCell() { - Vertex cell = new Cell(1); - Edge edge = new Adjacent(Keyboard.RIGHT, cell); - assertEquals(cell, edge.getCell()); - } - - @Test - public void testEquals() { - Vertex cell1 = new Cell(1); - Vertex cell2 = new Cell(2); - - Edge edge1 = new Adjacent(Keyboard.RIGHT, cell2); - Edge edge2 = new Adjacent(Keyboard.LEFT, cell1); - - assertEquals(edge1.getCell().click(Keyboard.RIGHT), cell2); - assertEquals(edge2.getCell().click(Keyboard.LEFT), cell1); - - } - -} diff --git a/jogo-oito/src/test/java/game/BoardTest.java b/jogo-oito/src/test/java/game/BoardTest.java index 7b39668f..945b7dff 100644 --- a/jogo-oito/src/test/java/game/BoardTest.java +++ b/jogo-oito/src/test/java/game/BoardTest.java @@ -4,39 +4,35 @@ */ package game; -/** - * - * @author allen - */ -import model.Cell; -import util.Board; -import interfaces.Edge; -import interfaces.Vertex; +import service.CellImpl; +import service.GraphImpl; +import service.interfaces.Edge; +import service.interfaces.Cell; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; import java.util.List; -import model.Keyboard; +import util.Keyboard; import org.junit.jupiter.api.Assertions; public class BoardTest { - private Board board; + private GraphImpl graphImpl; @BeforeEach - public void setUp() { - board = new Board(); - board.feedback(); + public void createVerticalAdjacent() { + graphImpl = new GraphImpl(); + graphImpl.feedback(); } @Test public void testSwap() { - Vertex emptyCell = board.getEmptyCell(); - Vertex cell = board.getCells().get(7); + Cell emptyCell = graphImpl.getEmptyCell(); + Cell cell = graphImpl.getCells().get(7); Integer cellValue = cell.getValue(); - board.click(cellValue); + graphImpl.click(cellValue); assertEquals(cellValue, emptyCell.getValue()); assertEquals(0, cell.getValue()); @@ -44,7 +40,7 @@ public void testSwap() { @Test public void testGetCells() { - List cells = board.getCells(); + List cells = graphImpl.getCells(); assertNotNull(cells); assertEquals(9, cells.size()); @@ -52,11 +48,11 @@ public void testGetCells() { @Test public void testDefineCellRelationships() { - Vertex cell1 = board.getCells().get(1); - Vertex cell2 = board.getCells().get(2); + Cell cell1 = graphImpl.getCells().get(1); + Cell cell2 = graphImpl.getCells().get(2); - Edge adjacent1 = cell1.getAdjacentByKeyCode(model.Keyboard.LEFT); - Edge adjacent2 = cell2.getAdjacentByKeyCode(model.Keyboard.RIGHT); + Edge adjacent1 = cell1.getAdjacentByKeyCode(Keyboard.LEFT); + Edge adjacent2 = cell2.getAdjacentByKeyCode(Keyboard.RIGHT); assertEquals(cell2, adjacent1.getCell()); assertEquals(cell1, adjacent2.getCell()); @@ -64,11 +60,11 @@ public void testDefineCellRelationships() { @Test public void testClick() { - Vertex emptyCell = board.getEmptyCell(); - Vertex cell = board.getCells().get(7); + Cell emptyCell = graphImpl.getEmptyCell(); + Cell cell = graphImpl.getCells().get(7); Integer cellValue = cell.getValue(); - board.click(cellValue); + graphImpl.click(cellValue); assertEquals(cellValue, emptyCell.getValue()); assertEquals(0, cell.getValue()); @@ -76,36 +72,36 @@ public void testClick() { @Test public void testCheckGameOver() { - Assertions.assertTrue(this.board.checkGameOver()); - board = new Board(); - board.setting(); - Assertions.assertFalse(board.checkGameOver()); + Assertions.assertTrue(this.graphImpl.checkGameOver()); + graphImpl = new GraphImpl(); + graphImpl.setter(); + Assertions.assertFalse(graphImpl.checkGameOver()); } @Test - public void testCellCreatingHorizontalAdjacent() { - Vertex cell1 = new Cell(1); - Vertex cell2 = new Cell(2); + public void testCellcreateHorizontalAdjacent() { + Cell cell1 = new CellImpl(1); + Cell cell2 = new CellImpl(2); - cell1.creatingHorizontalAdjacent(cell2); + cell1.createHorizontalAdjacent(cell2); - Edge adjacent1 = cell1.getAdjacentByKeyCode(model.Keyboard.LEFT); - Edge adjacent2 = cell2.getAdjacentByKeyCode(model.Keyboard.RIGHT); + Edge adjacent1 = cell1.getAdjacentByKeyCode(Keyboard.LEFT); + Edge adjacent2 = cell2.getAdjacentByKeyCode(Keyboard.RIGHT); assertEquals(cell2, adjacent1.getCell()); assertEquals(cell1, adjacent2.getCell()); } @Test - public void testCellCreatingVerticalAdjacent() { - Vertex cell1 = new Cell(1); - Vertex cell2 = new Cell(2); + public void testCellcreateVerticalAdjacent() { + Cell cell1 = new CellImpl(1); + Cell cell2 = new CellImpl(2); - cell1.creatingVerticalAdjacent(cell2); + cell1.createVerticalAdjacent(cell2); - Edge adjacent1 = cell1.getAdjacentByKeyCode(model.Keyboard.UP); - Edge adjacent2 = cell2.getAdjacentByKeyCode(model.Keyboard.DOWN); + Edge adjacent1 = cell1.getAdjacentByKeyCode(Keyboard.UP); + Edge adjacent2 = cell2.getAdjacentByKeyCode(Keyboard.DOWN); assertEquals(cell2, adjacent1.getCell()); assertEquals(cell1, adjacent2.getCell()); @@ -113,7 +109,7 @@ public void testCellCreatingVerticalAdjacent() { @Test public void testValueToText() { - Vertex cell = new Cell(0); + Cell cell = new CellImpl(0); assertEquals("", cell.valueToText()); cell.setValue(5); @@ -122,37 +118,37 @@ public void testValueToText() { @Test public void testGetAdjacentByKeyCode() { - Vertex cell1 = new Cell(1); - Vertex cell2 = new Cell(2); + Cell cell1 = new CellImpl(1); + Cell cell2 = new CellImpl(2); - cell1.creatingHorizontalAdjacent(cell2); + cell1.createHorizontalAdjacent(cell2); - Edge adjacent = cell1.getAdjacentByKeyCode(model.Keyboard.LEFT); + Edge adjacent = cell1.getAdjacentByKeyCode(Keyboard.LEFT); assertEquals(cell2, adjacent.getCell()); } @Test public void testClickDown() { - board.swap(Keyboard.DOWN.getValue()); - Assertions.assertEquals(5, board.getCells().indexOf(board.getEmptyCell())); + graphImpl.swap(Keyboard.DOWN.getValue()); + Assertions.assertEquals(5, graphImpl.getCells().indexOf(graphImpl.getEmptyCell())); } @Test public void testClickUp() { - board.swap(Keyboard.UP.getValue()); - Assertions.assertEquals(8, board.getCells().indexOf(board.getEmptyCell())); + graphImpl.swap(Keyboard.UP.getValue()); + Assertions.assertEquals(8, graphImpl.getCells().indexOf(graphImpl.getEmptyCell())); } @Test public void testClickRight() { - board.swap(Keyboard.RIGHT.getValue()); - Assertions.assertEquals(7, board.getCells().indexOf(board.getEmptyCell())); + graphImpl.swap(Keyboard.RIGHT.getValue()); + Assertions.assertEquals(7, graphImpl.getCells().indexOf(graphImpl.getEmptyCell())); } @Test public void testClickLeft() { - board.swap(Keyboard.LEFT.getValue()); - Assertions.assertEquals(8, board.getCells().indexOf(board.getEmptyCell())); + graphImpl.swap(Keyboard.LEFT.getValue()); + Assertions.assertEquals(8, graphImpl.getCells().indexOf(graphImpl.getEmptyCell())); } } diff --git a/jogo-oito/src/test/java/game/CellTest.java b/jogo-oito/src/test/java/game/CellTest.java deleted file mode 100644 index a2742248..00000000 --- a/jogo-oito/src/test/java/game/CellTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template - */ -package game; - -import interfaces.Edge; -import interfaces.Vertex; -import java.util.List; -import model.Adjacent; -import model.Cell; -import model.Keyboard; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -public class CellTest{ - - @Test - public void testSetValue() { - Vertex cell = new Cell(0); - cell.setValue(5); - assertEquals(5, cell.getValue()); - } - - @Test - public void testGetValue() { - Vertex cell = new Cell(10); - assertEquals(10, cell.getValue()); - } - - @Test - public void testCreatingHorizontalAdjacent() { - Vertex cell1 = new Cell(1); - Vertex cell2 = new Cell(2); - - cell1.creatingHorizontalAdjacent(cell2); - - assertEquals(1, cell1.getAdjacents().size()); - assertEquals(1, cell2.getAdjacents().size()); - } - - @Test - public void testCreatingVerticalAdjacent() { - Vertex cell1 = new Cell(1); - Vertex cell2 = new Cell(2); - - cell1.creatingVerticalAdjacent(cell2); - - assertEquals(1, cell1.getAdjacents().size()); - assertEquals(1, cell2.getAdjacents().size()); - } - - @Test - public void testValueToText() { - Vertex cell1 = new Cell(0); - Vertex cell2 = new Cell(5); - - assertEquals("", cell1.valueToText()); - assertEquals("5", cell2.valueToText()); - } - - @Test - public void testGetAdjacentByKeyCode() { - Vertex cell1 = new Cell(1); - Vertex cell2 = new Cell(2); - cell1.creatingHorizontalAdjacent(cell2); - - assertEquals(cell2, cell1.getAdjacentByKeyCode(Keyboard.LEFT).getCell()); - } - - @Test - public void testClick() { - Vertex cell1 = new Cell(1); - Vertex cell2 = new Cell(2); - cell1.creatingHorizontalAdjacent(cell2); - - assertEquals(cell2, cell1.click(Keyboard.LEFT)); - } - - @Test - public void testSwapCells() { - Vertex cell1 = new Cell(0); - Vertex cell2 = new Cell(2); - cell1.creatingHorizontalAdjacent(cell2); - - cell1.swapCells(cell2.getValue()); - - assertEquals(2, cell1.getValue()); - assertEquals(0, cell2.getValue()); - } - - @Test - public void testAddAdjacents() { - Vertex cell1 = new Cell(1); - Vertex cell2 = new Cell(2); - Edge edge = new Adjacent(Keyboard.RIGHT, cell2); - - cell1.addAdjacents(edge); - - List adjacents = cell1.getAdjacents(); - assertEquals(1, adjacents.size()); - assertEquals(edge, adjacents.get(0)); - } - - @Test - public void defineAdjacents() { - Vertex cell1 = new Cell(5); - Vertex cell2 = new Cell(10); - Vertex cell3 = new Cell(15); - Vertex cell4 = new Cell(20); - - cell1.creatingVerticalAdjacent(cell2); - cell1.creatingVerticalAdjacent(cell3); - cell1.creatingHorizontalAdjacent(cell4); - - List adjacents = cell1.getAdjacents(); - assertEquals(cell2, adjacents.get(0).getCell()); - assertEquals(cell3, adjacents.get(1).getCell()); - assertEquals(cell4, adjacents.get(2).getCell()); - } -} From 2eb1f800400c06dbf25631126b7ed36672933abd Mon Sep 17 00:00:00 2001 From: Patrick Azevedo Date: Wed, 18 Oct 2023 17:15:53 -0300 Subject: [PATCH 2/2] Criado o projeto --- .idea/.gitignore | 8 ++ .idea/.name | 1 + .idea/misc.xml | 6 + .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 + .../src/main/java/controller/Controller.java | 40 ++++++ jogo-oito/src/main/java/service/CellImpl.java | 111 ++++++++++++++++ jogo-oito/src/main/java/service/EdgeImpl.java | 42 ++++++ .../src/main/java/service/GraphImpl.java | 97 ++++++++++++++ .../main/java/service/interfaces/Cell.java | 36 ++++++ .../main/java/service/interfaces/Edge.java | 19 +++ .../main/java/service/interfaces/Graph.java | 28 ++++ jogo-oito/src/main/java/util/Keyboard.java | 38 ++++++ .../src/test/java/game/CellImplTest.java | 122 ++++++++++++++++++ .../src/test/java/game/EdgeImplTest.java | 39 ++++++ senior-developer-challenge.iml | 9 ++ 16 files changed, 610 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/.name create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 jogo-oito/src/main/java/controller/Controller.java create mode 100644 jogo-oito/src/main/java/service/CellImpl.java create mode 100644 jogo-oito/src/main/java/service/EdgeImpl.java create mode 100644 jogo-oito/src/main/java/service/GraphImpl.java create mode 100644 jogo-oito/src/main/java/service/interfaces/Cell.java create mode 100644 jogo-oito/src/main/java/service/interfaces/Edge.java create mode 100644 jogo-oito/src/main/java/service/interfaces/Graph.java create mode 100644 jogo-oito/src/main/java/util/Keyboard.java create mode 100644 jogo-oito/src/test/java/game/CellImplTest.java create mode 100644 jogo-oito/src/test/java/game/EdgeImplTest.java create mode 100644 senior-developer-challenge.iml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 00000000..38a05237 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +jogo-do-oito-do-estagiario-gpt \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..d972cff6 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..24b10e54 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/jogo-oito/src/main/java/controller/Controller.java b/jogo-oito/src/main/java/controller/Controller.java new file mode 100644 index 00000000..add77001 --- /dev/null +++ b/jogo-oito/src/main/java/controller/Controller.java @@ -0,0 +1,40 @@ +package controller; + +import service.interfaces.Cell; +import java.util.List; +import service.GraphImpl; + +public class Controller { + + private final service.interfaces.Graph graph; + + public Controller() { + this.graph = new GraphImpl(); + } + + public void feedback() { + this.graph.feedback(); + } + + public void setter() { + this.graph.setter(); + } + + public List getCells() { + return this.graph.getCells(); + } + + public void swap(Integer keyCode) { + this.graph.swap(keyCode); + } + + public Boolean checkGameOver() { + return this.graph.checkGameOver(); + + } + + public void click(Integer cellValue) { + this.graph.click(cellValue); + } + +} diff --git a/jogo-oito/src/main/java/service/CellImpl.java b/jogo-oito/src/main/java/service/CellImpl.java new file mode 100644 index 00000000..ea5e3ae2 --- /dev/null +++ b/jogo-oito/src/main/java/service/CellImpl.java @@ -0,0 +1,111 @@ +package service; + +import service.interfaces.Cell; +import service.interfaces.Edge; +import util.Keyboard; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +public class CellImpl implements Cell { + + private Integer value; + private final List adjacents; + public static Integer content; + + public CellImpl(Integer value) { + this.value = value; + this.adjacents = new ArrayList<>(); + } + + public CellImpl() { + this.value = CellImpl.content++; + this.adjacents = new ArrayList<>(); + } + + @Override + public void setValue(Integer value) { + this.value = value; + } + + @Override + public Integer getValue() { + return this.value; + } + + @Override + public void createHorizontalAdjacent(service.interfaces.Cell cell) { + this.adjacents.add(new EdgeImpl(Keyboard.LEFT, cell)); + cell.getAdjacents().add(new EdgeImpl(Keyboard.RIGHT, this)); + } + + @Override + public void createVerticalAdjacent(service.interfaces.Cell cell) { + this.adjacents.add(new EdgeImpl(Keyboard.UP, cell)); + cell.getAdjacents().add(new EdgeImpl(Keyboard.DOWN, this)); + } + + @Override + public String valueToText() { + return Optional.of(this.value) + .filter(value -> value != 0) + .map(String::valueOf) + .orElse(""); + } + + @Override + public Edge getAdjacentByKeyCode(Keyboard key) { + EdgeImpl edge = new EdgeImpl(key, null); + Integer indexEdge = this.adjacents.indexOf(edge); + return Optional.of(indexEdge) + .filter(index -> index != -1) + .map(this.adjacents::get) + .orElse(null); + } + + @Override + public service.interfaces.Cell click(Keyboard key) { + Edge adjacent = this.getAdjacentByKeyCode(key); + return this.movement(adjacent); + } + + private service.interfaces.Cell movement(Edge adjacent) { + return Optional.ofNullable(adjacent) + .map(Edge::getCell) + .map(this::swapCells) + .orElse(this); + } + + private service.interfaces.Cell swapCells(service.interfaces.Cell movementCell) { + this.setValue(movementCell.getValue()); + movementCell.setValue(0); + return movementCell; + } + + @Override + public service.interfaces.Cell swapCells(Integer value) { + return this.adjacents.stream() + .filter(adjacent -> Objects.equals(adjacent.getCell().getValue(), value)) + .findFirst() + .map(this::movement) + .orElse(this); + } + + @Override + public List getAdjacents() { + return this.adjacents; + } + + @Override + public void addAdjacent(Edge edge) { + this.adjacents.add(edge); + } + + @Override + public boolean equals(Object obj) { + return Objects.equals(this.value, ((CellImpl) obj).value); + } + +} diff --git a/jogo-oito/src/main/java/service/EdgeImpl.java b/jogo-oito/src/main/java/service/EdgeImpl.java new file mode 100644 index 00000000..2205b6c7 --- /dev/null +++ b/jogo-oito/src/main/java/service/EdgeImpl.java @@ -0,0 +1,42 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package service; + +import service.interfaces.Edge; +import service.interfaces.Cell; +import util.Keyboard; + +import java.util.Objects; + +/** + * + * @author allen + */ +public class EdgeImpl implements Edge{ + + private final Keyboard key; + private final Cell cell; + + public EdgeImpl(Keyboard key, Cell cell) { + this.key = key; + this.cell = cell; + } + + @Override + public Keyboard getKey() { + return this.key; + } + + @Override + public Cell getCell() { + return this.cell; + } + + @Override + public boolean equals(Object obj) { + return Objects.equals(((EdgeImpl) obj).getKey(), this.getKey()); + } + +} diff --git a/jogo-oito/src/main/java/service/GraphImpl.java b/jogo-oito/src/main/java/service/GraphImpl.java new file mode 100644 index 00000000..1178fdbe --- /dev/null +++ b/jogo-oito/src/main/java/service/GraphImpl.java @@ -0,0 +1,97 @@ +package service; + +import model.Matrix; +import service.interfaces.Cell; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.Optional; +import java.util.stream.IntStream; + +import service.interfaces.Graph; +import util.Keyboard; + +public class GraphImpl implements Graph { + + private List cells; + private Cell emptyCell; + private Integer length; + private Matrix matrix; + + public GraphImpl() { + } + + @Override + public void feedback() { + this.matrix = new Matrix(); + this.cells = this.matrix.getCells(); + this.length = cells.size(); + this.defineEmptyCell(); + } + + @Override + public void setter() { + this.matrix = new Matrix(); + this.cells = this.matrix.getCells(); + this.length = cells.size(); + this.shuffleCell(); + this.defineEmptyCell(); + + } + + private void shuffleCell() { + Iterator iterator = this.shuffleValues().iterator(); + this.cells + .forEach(vertex -> vertex.setValue(iterator.next())); + } + + private List shuffleValues() { + List values = new ArrayList<>(); + this.cells.stream() + .map(Cell::getValue) + .forEach(values::add); + Collections.shuffle(values); + return values; + } + + private void defineEmptyCell() { + Optional minCell = this.cells.stream() + .min(Comparator.comparing(Cell::getValue)); + minCell.ifPresent(this::accept); + } + + + @Override + public void click(Integer cellValue) { + this.emptyCell = this.emptyCell.swapCells(cellValue); + } + + @Override + public void swap(Integer keyCode) { + Keyboard key = Keyboard.fromValue(keyCode); + this.emptyCell = this.emptyCell.click(key); + } + + @Override + public List getCells() { + return this.cells; + } + + @Override + public Cell getEmptyCell() { + return this.emptyCell; + } + + @Override + public Boolean checkGameOver() { + return IntStream.range(0, this.length) + .allMatch(index -> this.cells.get(index).getValue() == (index + 1) % this.length); + + } + + private void accept(Cell cell) { + this.emptyCell = cell; + } +} diff --git a/jogo-oito/src/main/java/service/interfaces/Cell.java b/jogo-oito/src/main/java/service/interfaces/Cell.java new file mode 100644 index 00000000..49ac0d48 --- /dev/null +++ b/jogo-oito/src/main/java/service/interfaces/Cell.java @@ -0,0 +1,36 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package service.interfaces; + +import java.util.List; +import util.Keyboard; + +/** + * + * @author allen + */ +public interface Cell { + + void setValue(Integer value); + + Integer getValue(); + + void createHorizontalAdjacent(Cell cell); + + void createVerticalAdjacent(Cell cell); + + String valueToText(); + + Edge getAdjacentByKeyCode(Keyboard key); + + Cell click(Keyboard key); + + List getAdjacents(); + + void addAdjacent(Edge edge); + + Cell swapCells(Integer value); + +} diff --git a/jogo-oito/src/main/java/service/interfaces/Edge.java b/jogo-oito/src/main/java/service/interfaces/Edge.java new file mode 100644 index 00000000..38a53574 --- /dev/null +++ b/jogo-oito/src/main/java/service/interfaces/Edge.java @@ -0,0 +1,19 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package service.interfaces; + +import util.Keyboard; + +/** + * + * @author allen + */ +public interface Edge { + + Keyboard getKey(); + + Cell getCell(); + +} diff --git a/jogo-oito/src/main/java/service/interfaces/Graph.java b/jogo-oito/src/main/java/service/interfaces/Graph.java new file mode 100644 index 00000000..2ad26b8c --- /dev/null +++ b/jogo-oito/src/main/java/service/interfaces/Graph.java @@ -0,0 +1,28 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package service.interfaces; + +import java.util.List; + +/** + * + * @author allen + */ +public interface Graph { + + void feedback(); + + void setter(); + + void swap(Integer keyCode); + + List getCells(); + + Cell getEmptyCell(); + + void click(Integer cellValue); + + Boolean checkGameOver(); +} diff --git a/jogo-oito/src/main/java/util/Keyboard.java b/jogo-oito/src/main/java/util/Keyboard.java new file mode 100644 index 00000000..2ae2a05e --- /dev/null +++ b/jogo-oito/src/main/java/util/Keyboard.java @@ -0,0 +1,38 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package util; + +import java.awt.event.KeyEvent; +import java.util.Arrays; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +public enum Keyboard { + + UP(KeyEvent.VK_UP), + DOWN(KeyEvent.VK_DOWN), + LEFT(KeyEvent.VK_LEFT), + RIGHT(KeyEvent.VK_RIGHT); + + private final Integer value; + + private static final Map map = Arrays.stream(Keyboard.values()) + .collect(Collectors.toMap(Keyboard::getValue, Function.identity())); + + + Keyboard(Integer value) { + this.value = value; + } + + public Integer getValue() { + return value; + } + + public static Keyboard fromValue(Integer value) { + return map.get(value); + } + +} diff --git a/jogo-oito/src/test/java/game/CellImplTest.java b/jogo-oito/src/test/java/game/CellImplTest.java new file mode 100644 index 00000000..7a197527 --- /dev/null +++ b/jogo-oito/src/test/java/game/CellImplTest.java @@ -0,0 +1,122 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package game; + +import service.CellImpl; +import service.interfaces.Edge; +import service.interfaces.Cell; +import java.util.List; +import service.EdgeImpl; +import util.Keyboard; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class CellImplTest { + + @Test + public void testSetValue() { + Cell cell = new CellImpl(0); + cell.setValue(5); + assertEquals(5, cell.getValue()); + } + + @Test + public void testGetValue() { + Cell cell = new CellImpl(10); + assertEquals(10, cell.getValue()); + } + + @Test + public void testcreateHorizontalAdjacent() { + Cell cell1 = new CellImpl(1); + Cell cell2 = new CellImpl(2); + + cell1.createHorizontalAdjacent(cell2); + + assertEquals(1, cell1.getAdjacents().size()); + assertEquals(1, cell2.getAdjacents().size()); + } + + @Test + public void testcreateVerticalAdjacent() { + Cell cell1 = new CellImpl(1); + Cell cell2 = new CellImpl(2); + + cell1.createVerticalAdjacent(cell2); + + assertEquals(1, cell1.getAdjacents().size()); + assertEquals(1, cell2.getAdjacents().size()); + } + + @Test + public void testValueToText() { + Cell cell1 = new CellImpl(0); + Cell cell2 = new CellImpl(5); + + assertEquals("", cell1.valueToText()); + assertEquals("5", cell2.valueToText()); + } + + @Test + public void testGetAdjacentByKeyCode() { + Cell cell1 = new CellImpl(1); + Cell cell2 = new CellImpl(2); + cell1.createHorizontalAdjacent(cell2); + + assertEquals(cell2, cell1.getAdjacentByKeyCode(Keyboard.LEFT).getCell()); + } + + @Test + public void testClick() { + Cell cell1 = new CellImpl(1); + Cell cell2 = new CellImpl(2); + cell1.createHorizontalAdjacent(cell2); + + assertEquals(cell2, cell1.click(Keyboard.LEFT)); + } + + @Test + public void testSwapCells() { + Cell cell1 = new CellImpl(0); + Cell cell2 = new CellImpl(2); + cell1.createHorizontalAdjacent(cell2); + + cell1.swapCells(cell2.getValue()); + + assertEquals(2, cell1.getValue()); + assertEquals(0, cell2.getValue()); + } + + @Test + public void testAddAdjacents() { + Cell cell1 = new CellImpl(1); + Cell cell2 = new CellImpl(2); + Edge edge = new EdgeImpl(Keyboard.RIGHT, cell2); + + cell1.addAdjacent(edge); + + List adjacents = cell1.getAdjacents(); + assertEquals(1, adjacents.size()); + assertEquals(edge, adjacents.get(0)); + } + + @Test + public void defineAdjacents() { + Cell cell1 = new CellImpl(5); + Cell cell2 = new CellImpl(10); + Cell cell3 = new CellImpl(15); + Cell cell4 = new CellImpl(20); + + cell1.createVerticalAdjacent(cell2); + cell1.createVerticalAdjacent(cell3); + cell1.createHorizontalAdjacent(cell4); + + List adjacents = cell1.getAdjacents(); + assertEquals(cell2, adjacents.get(0).getCell()); + assertEquals(cell3, adjacents.get(1).getCell()); + assertEquals(cell4, adjacents.get(2).getCell()); + } +} diff --git a/jogo-oito/src/test/java/game/EdgeImplTest.java b/jogo-oito/src/test/java/game/EdgeImplTest.java new file mode 100644 index 00000000..5d297683 --- /dev/null +++ b/jogo-oito/src/test/java/game/EdgeImplTest.java @@ -0,0 +1,39 @@ +package game; + +import service.CellImpl; +import service.EdgeImpl; +import util.Keyboard; +import service.interfaces.Edge; +import service.interfaces.Cell; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +public class EdgeImplTest { + + @Test + public void testGetKey() { + Edge edge = new EdgeImpl(Keyboard.RIGHT, null); + assertEquals(Keyboard.RIGHT, edge.getKey()); + } + + @Test + public void testGetCell() { + Cell cell = new CellImpl(1); + Edge edge = new EdgeImpl(Keyboard.RIGHT, cell); + assertEquals(cell, edge.getCell()); + } + + @Test + public void testEquals() { + Cell cell1 = new CellImpl(1); + Cell cell2 = new CellImpl(2); + + Edge edge1 = new EdgeImpl(Keyboard.RIGHT, cell2); + Edge edge2 = new EdgeImpl(Keyboard.LEFT, cell1); + + assertEquals(edge1.getCell().click(Keyboard.RIGHT), cell2); + assertEquals(edge2.getCell().click(Keyboard.LEFT), cell1); + + } + +} diff --git a/senior-developer-challenge.iml b/senior-developer-challenge.iml new file mode 100644 index 00000000..48426fcc --- /dev/null +++ b/senior-developer-challenge.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file