Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
65 changes: 36 additions & 29 deletions jogo-oito/pom.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
<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>
<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>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand All @@ -52,4 +59,4 @@
<type>jar</type>
</dependency>
</dependencies>
</project>
</project>
14 changes: 9 additions & 5 deletions jogo-oito/src/main/java/facade/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
import interfaces.Graph;
import interfaces.Vertex;
import java.util.List;

import util.Board;

/**
* Classe que representa o controlador do jogo.
*
* @author quintino
*/
public class Controller {

private final Graph board;
private final Graph board = new Board();

public Controller() {
this.board = new Board();
this.setting();
}

public void feedback() {
this.board.feedback();
}
Expand All @@ -31,7 +36,6 @@ public void swap(Integer keyCode) {

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

}

public void click(Integer cellValue) {
Expand Down
10 changes: 2 additions & 8 deletions jogo-oito/src/main/java/interfaces/Edge.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
/*
* 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;

/**
* Interface que representa uma aresta do jogo.
*
* @author allen
* @author quintino
*/
public interface Edge {

Keyboard getKey();

Vertex getCell();

}
14 changes: 2 additions & 12 deletions jogo-oito/src/main/java/interfaces/Graph.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
/*
* 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;

/**
* Interface que representa o grafo do jogo.
*
* @author allen
* @author quintino
*/
public interface Graph {

void feedback();

void setting();

void swap(Integer keyCode);

List<Vertex> getCells();

Vertex getEmptyCell();

void click(Integer cellValue);

Boolean checkGameOver();
}
18 changes: 2 additions & 16 deletions jogo-oito/src/main/java/interfaces/Vertex.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
/*
* 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;

/**
* Interface que representa um vértice do jogo.
*
* @author allen
* @author quintino
*/
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<Edge> getAdjacents();

void addAdjacents(Edge edge);

Vertex swapCells(Integer value);

}
38 changes: 10 additions & 28 deletions jogo-oito/src/main/java/model/Adjacent.java
Original file line number Diff line number Diff line change
@@ -1,40 +1,22 @@
/*
* 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 lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Objects;

/**
* Classe que representa uma aresta do jogo.
*
* @author allen
* @author quintino
*/
public class Adjacent implements Edge{

@Data
@AllArgsConstructor
@EqualsAndHashCode
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());
}

}
31 changes: 10 additions & 21 deletions jogo-oito/src/main/java/model/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@

import interfaces.Edge;
import interfaces.Vertex;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

/**
* Classe que representa uma célula do jogo.
*
* @author quintino
*/
@Data
@EqualsAndHashCode
public class Cell implements Vertex {

private Integer value;
private final List<Edge> adjacents;
public static Integer content;
Expand All @@ -23,16 +32,6 @@ public Cell() {
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));
Expand Down Expand Up @@ -91,19 +90,9 @@ public Vertex swapCells(Integer value) {
.orElse(this);
}

@Override
public List<Edge> 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);
}

}
15 changes: 7 additions & 8 deletions jogo-oito/src/main/java/model/Keyboard.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* 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;
Expand All @@ -10,18 +6,21 @@
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* Enum que representa as teclas do teclado.
*
* @author quintino
*/
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<Integer, Keyboard> map = Arrays.stream(Keyboard.values())
.collect(Collectors.toMap(Keyboard::getValue, Function.identity()));

private static final Map<Integer, Keyboard> map =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boa Tarde,
Objetos devem trocar mensagens.
O objetivo é uso de POO, o uso de programação funcional atrapalha na coesão.

Att.

Arrays.stream(Keyboard.values()).collect(Collectors.toMap(Keyboard::getValue, Function.identity()));

Keyboard(Integer value) {
this.value = value;
Expand Down
Loading