Skip to content

Pull Request - Desenvolvedor Pleno #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
de5b122
Corrige exception ao clicar na célula em branco
flipChandler Jul 22, 2023
e496558
Renomeia métodos em JogoDosOito
flipChandler Jul 22, 2023
54d5177
Adiciona JogoDosOitoBuilder e testes unitários
flipChandler Jul 22, 2023
c927dc1
Adiciona método main em Application
flipChandler Jul 22, 2023
065462c
Refatora as classes Adjacent, Cell, Edge, JogoDosOito e testes unitários
flipChandler Jul 22, 2023
0488141
Refatora as classes Controller, Graph, Board e testes unitários
flipChandler Jul 22, 2023
eedbd80
Refatora enum Keyboard
flipChandler Jul 22, 2023
e0a0989
Refatora classes Matrix, Vertex e testes unitários
flipChandler Jul 22, 2023
6444a10
Adiciona centralizar Frame na tela ao iniciar o jogo
flipChandler Jul 22, 2023
7aaf7a9
Adiciona JTattoo pra otimizar UI do jogo
flipChandler Jul 22, 2023
6d64eed
Review do código, renomeia métodos e testes
flipChandler Jul 22, 2023
0a7753c
Adiciona classe Movement e corrige testes unitários
flipChandler Jul 25, 2023
fff3dfb
Corrige instaciação de movement em Board.click()
flipChandler Jul 25, 2023
c3fc8e2
Remove Movement de Cell
flipChandler Jul 26, 2023
9bf02e8
Adiciona classe Click e teste unitário
flipChandler Jul 26, 2023
438c822
Remove length da classe Board
flipChandler Jul 26, 2023
13b174d
Adiciona método of na classe Movement
flipChandler Jul 27, 2023
08ca6fd
Refatora loop na classe Board e JogoDosOito
flipChandler Jul 28, 2023
b8df829
Adiciona a classe JFrameCustom e teste unitário
flipChandler Jul 28, 2023
639a5d2
Adiciona melhoria no teste unitário em JogoDosOitoBuilderTest
flipChandler Jul 30, 2023
7e8784a
Adiciona padrão Command na classe Click
flipChandler Jul 30, 2023
5a6a528
Adiciona melhoria no teste unitário em MatrixTest
flipChandler Jul 30, 2023
a242822
Adiciona padrão do JUnit 5 nos testes unitários
flipChandler Jul 30, 2023
b762533
Adiciona melhoria no try/catch de Application.main()
flipChandler Jul 30, 2023
4f7507a
Adiciona interface Status
flipChandler Jul 30, 2023
2b59842
Corrige nome de parâmetro em Movement
flipChandler Jul 31, 2023
13f3848
Adiciona Interface Segregation Principle em JogoDosOito
flipChandler Aug 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 46 additions & 31 deletions jogo-oito/pom.xml
Original file line number Diff line number Diff line change
@@ -1,55 +1,70 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bempaggo.jogo</groupId>
<artifactId>jogo-do-oito-do-estagiario-gpt</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>rest-unity-test</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>18</source>
<target>18</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</build>
<dependencies>
<modelVersion>4.0.0</modelVersion>
<groupId>com.bempaggo.jogo</groupId>
<artifactId>jogo-do-oito-do-estagiario-gpt</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit-jupiter-api.version>5.9.2</junit-jupiter-api.version>
<junit.version>4.13.2</junit.version>
<assertj-core.version>3.24.2</assertj-core.version>
<jtattoo.version>1.6.13</jtattoo.version>
</properties>
<build>
<finalName>rest-unity-test</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>18</source>
<target>18</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.0</version>
<version>${junit-jupiter-api.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.6.0</version>
<version>${junit-jupiter-api.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.0</version>
<version>${junit-jupiter-api.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<version>${junit.version}</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-core.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jtattoo</groupId>
<artifactId>JTattoo</artifactId>
<version>${jtattoo.version}</version>
</dependency>
</dependencies>
</project>
22 changes: 22 additions & 0 deletions jogo-oito/src/main/java/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import builder.JogoDosOitoBuilder;
import view.JogoDosOito;

import javax.swing.*;

public class Application {

public static void main(String[] args) {
new JogoDosOitoBuilder()
.createButtons()
.configureMenu()
.configureInterface()
.build();
try {
UIManager.setLookAndFeel("com.jtattoo.plaf.aluminium.AluminiumLookAndFeel");
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(JogoDosOito.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(() -> new JogoDosOito().setVisible(true));
}

}
31 changes: 31 additions & 0 deletions jogo-oito/src/main/java/builder/JogoDosOitoBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package builder;

import view.JogoDosOito;

public class JogoDosOitoBuilder {

private JogoDosOito jogoDosOito;

public JogoDosOitoBuilder() {
this.jogoDosOito = new JogoDosOito();
}

public JogoDosOitoBuilder createButtons() {
this.jogoDosOito.createButtons();
return this;
}

public JogoDosOitoBuilder configureMenu() {
this.jogoDosOito.configureMenu();
return this;
}

public JogoDosOitoBuilder configureInterface() {
this.jogoDosOito.configureInterface();
return this;
}

public JogoDosOito build() {
return this.jogoDosOito;
}
}
7 changes: 7 additions & 0 deletions jogo-oito/src/main/java/command/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package command;

public interface Command {

void execute();

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
* 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;
package enums;

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 {

Expand All @@ -19,20 +15,8 @@ public enum Keyboard {

private final Integer value;

private static final Map<Integer, Keyboard> 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);
}

}
23 changes: 14 additions & 9 deletions jogo-oito/src/main/java/facade/Controller.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
package facade;

import command.Command;
import interfaces.Graph;
import interfaces.Status;
import interfaces.Vertex;
import java.util.List;
import util.Board;
import util.Click;
import util.GameStatus;

import java.util.List;

public class Controller {

private final Graph board;
private final Status gameStatus;
private final Command click;

public Controller() {
this.board = new Board();
this.gameStatus = GameStatus.of(this.board);
this.click = Click.of(this.board);
}

public void feedback() {
Expand All @@ -25,17 +34,13 @@ public List<Vertex> getCells() {
return this.board.getCells();
}

public void swap(Integer keyCode) {
this.board.swap(keyCode);
}

public Boolean checkGameOver() {
return this.board.checkGameOver();

return this.gameStatus.isOver();
}

public void click(Integer cellValue) {
this.board.click(cellValue);
public void click(Integer currentCellValue) {
this.board.setCurrentCellValue(currentCellValue);
this.click.execute();
}

}
7 changes: 7 additions & 0 deletions jogo-oito/src/main/java/interfaces/Action.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package interfaces;

public interface Action {

Vertex swapCells(Integer currentCellValue);

}
5 changes: 3 additions & 2 deletions jogo-oito/src/main/java/interfaces/Edge.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
package interfaces;

import model.Keyboard;
import enums.Keyboard;

/**
*
Expand All @@ -15,5 +15,6 @@ public interface Edge {
Keyboard getKey();

Vertex getCell();


Boolean cellValueIsEqual(Integer value);
}
9 changes: 5 additions & 4 deletions jogo-oito/src/main/java/interfaces/Graph.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ public interface Graph {

void setting();

void swap(Integer keyCode);

List<Vertex> getCells();

Vertex getEmptyCell();

void click(Integer cellValue);
void setEmptyCell(Vertex cell);

void setCurrentCellValue(Integer cellValue);

Integer getCurrentCellValue();

Boolean checkGameOver();
}
6 changes: 6 additions & 0 deletions jogo-oito/src/main/java/interfaces/Status.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package interfaces;

public interface Status {

Boolean isOver();
}
11 changes: 4 additions & 7 deletions jogo-oito/src/main/java/interfaces/Vertex.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
*/
package interfaces;

import enums.Keyboard;

import java.util.List;
import model.Keyboard;

/**
*
Expand All @@ -17,20 +18,16 @@ public interface Vertex {

Integer getValue();

void creatingHorizontalAdjacent(Vertex cell);
void createHorizontalAdjacent(Vertex cell);

void creatingVerticalAdjacent(Vertex cell);
void createVerticalAdjacent(Vertex cell);

String valueToText();

Edge getAdjacentByKeyCode(Keyboard key);

Vertex click(Keyboard key);

List<Edge> getAdjacents();

void addAdjacents(Edge edge);

Vertex swapCells(Integer value);

}
18 changes: 17 additions & 1 deletion jogo-oito/src/main/java/model/Adjacent.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
*/
package model;

import enums.Keyboard;
import interfaces.Edge;
import interfaces.Vertex;

import java.util.Objects;

/**
Expand All @@ -17,11 +19,15 @@ public class Adjacent implements Edge{
private final Keyboard key;
private final Vertex cell;

public Adjacent(Keyboard key, Vertex cell) {
private Adjacent(Keyboard key, Vertex cell) {
this.key = key;
this.cell = cell;
}

public static Adjacent of(Keyboard key, Vertex cell) {
return new Adjacent(key, cell);
}

@Override
public Keyboard getKey() {
return this.key;
Expand All @@ -32,9 +38,19 @@ public Vertex getCell() {
return this.cell;
}

@Override
public Boolean cellValueIsEqual(Integer value) {
return this.getCell().getValue().equals(value);
}

@Override
public boolean equals(Object obj) {
return Objects.equals(((Adjacent) obj).getKey(), this.getKey());
}

@Override
public int hashCode() {
return Objects.hash(key);
}

}
Loading