diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e10e727
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/.metadata/
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /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 0000000..38a0523
--- /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 0000000..d61655f
--- /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 0000000..24b10e5
--- /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 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Testar/.classpath b/Testar/.classpath
new file mode 100644
index 0000000..57bca72
--- /dev/null
+++ b/Testar/.classpath
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/Testar/.project b/Testar/.project
new file mode 100644
index 0000000..860481a
--- /dev/null
+++ b/Testar/.project
@@ -0,0 +1,17 @@
+
+
+ Testar
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/Testar/.settings/org.eclipse.jdt.core.prefs b/Testar/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..8c9943d
--- /dev/null
+++ b/Testar/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,14 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=17
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=17
diff --git a/Testar/bin/module-info.class b/Testar/bin/module-info.class
new file mode 100644
index 0000000..0e16021
Binary files /dev/null and b/Testar/bin/module-info.class differ
diff --git a/Testar/bin/teste/FizzBuzz.class b/Testar/bin/teste/FizzBuzz.class
new file mode 100644
index 0000000..77baeff
Binary files /dev/null and b/Testar/bin/teste/FizzBuzz.class differ
diff --git a/Testar/bin/teste/MarvinMusicAnalyzer.class b/Testar/bin/teste/MarvinMusicAnalyzer.class
new file mode 100644
index 0000000..f390b2b
Binary files /dev/null and b/Testar/bin/teste/MarvinMusicAnalyzer.class differ
diff --git a/Testar/src/module-info.java b/Testar/src/module-info.java
new file mode 100644
index 0000000..c20656a
--- /dev/null
+++ b/Testar/src/module-info.java
@@ -0,0 +1,2 @@
+module Testar {
+}
\ No newline at end of file
diff --git a/Testar/src/teste/FizzBuzz.java b/Testar/src/teste/FizzBuzz.java
new file mode 100644
index 0000000..aa172fb
--- /dev/null
+++ b/Testar/src/teste/FizzBuzz.java
@@ -0,0 +1,23 @@
+package teste;
+
+public class FizzBuzz {
+
+ public static void main(String[] args) {
+ printFizzBuzz();
+ }
+
+ public static void printFizzBuzz() {
+ for (int i = 1; i <= 100; i++) {
+ if (i % 3 == 0 && i % 5 == 0) {
+ System.out.println("FizzBuzz");
+ } else if (i % 3 == 0) {
+ System.out.println("Fizz");
+ } else if (i % 5 == 0) {
+ System.out.println("Buzz");
+ } else {
+ System.out.println(i);
+ }
+ }
+ }
+
+}
diff --git a/Testar/src/teste/MarvinMusicAnalyzer.java b/Testar/src/teste/MarvinMusicAnalyzer.java
new file mode 100644
index 0000000..136195b
--- /dev/null
+++ b/Testar/src/teste/MarvinMusicAnalyzer.java
@@ -0,0 +1,53 @@
+package teste;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class MarvinMusicAnalyzer {
+
+ public static int[] getRareNotes(int[] notes) {
+ Map noteFrequency = new HashMap<>();
+
+ // Count the frequency of each note
+ for (int note : notes) {
+ noteFrequency.put(note, noteFrequency.getOrDefault(note, 0) + 1);
+ }
+
+ // Find the rare notes
+ List rareNotes = new ArrayList<>();
+ for (Map.Entry entry : noteFrequency.entrySet()) {
+ if (entry.getValue() == 1) {
+ rareNotes.add(entry.getKey());
+ }
+ }
+
+ // Convert the List to int[]
+ if (rareNotes.isEmpty()) {
+ return null;
+ } else {
+ int[] rareNotesArray = new int[rareNotes.size()];
+ for (int i = 0; i < rareNotes.size(); i++) {
+ rareNotesArray[i] = rareNotes.get(i);
+ }
+ return rareNotesArray;
+ }
+ }
+
+ public static void main(String[] args) {
+ int[] notes = {1, 2, 3, 2, 2, 1, 5, 5};
+ int[] rareNotes = getRareNotes(notes);
+
+ if (rareNotes == null) {
+ System.out.println("No rare notes in the song.");
+ } else {
+ System.out.print("Rare notes: ");
+ for (int note : rareNotes) {
+ System.out.print(note + " ");
+ }
+ System.out.println();
+ }
+ }
+
+}
diff --git a/jogo-oito/.classpath b/jogo-oito/.classpath
index 1d97b2f..49d12bb 100644
--- a/jogo-oito/.classpath
+++ b/jogo-oito/.classpath
@@ -13,7 +13,7 @@
-
+
@@ -23,5 +23,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/jogo-oito/.settings/org.eclipse.jdt.apt.core.prefs b/jogo-oito/.settings/org.eclipse.jdt.apt.core.prefs
new file mode 100644
index 0000000..d4313d4
--- /dev/null
+++ b/jogo-oito/.settings/org.eclipse.jdt.apt.core.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.apt.aptEnabled=false
diff --git a/jogo-oito/.settings/org.eclipse.jdt.core.prefs b/jogo-oito/.settings/org.eclipse.jdt.core.prefs
index bc0c2ff..c9d1e55 100644
--- a/jogo-oito/.settings/org.eclipse.jdt.core.prefs
+++ b/jogo-oito/.settings/org.eclipse.jdt.core.prefs
@@ -1,8 +1,9 @@
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=18
-org.eclipse.jdt.core.compiler.compliance=18
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
+org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
-org.eclipse.jdt.core.compiler.source=18
+org.eclipse.jdt.core.compiler.source=17
diff --git a/jogo-oito/src/main/java/chat/gpt/Celula.java b/jogo-oito/src/main/java/chat/gpt/Celula.java
new file mode 100644
index 0000000..3f77f49
--- /dev/null
+++ b/jogo-oito/src/main/java/chat/gpt/Celula.java
@@ -0,0 +1,40 @@
+package chat.gpt;
+
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+
+public class Celula extends JButton{
+ private int valor;
+
+ public Celula(int valor) {
+ this.valor = valor;
+ setFont(new Font("Arial", Font.BOLD, 36));
+ setText(getValorFormatado());
+ addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ // Implemente a ação de clique na célula aqui
+ Tabuleiro tabuleiro = new Tabuleiro();
+ tabuleiro.reiniciar();
+ }
+ });
+ }
+
+ public void setValor(int valor) {
+ this.valor = valor;
+ setText(getValorFormatado());
+ }
+
+ private String getValorFormatado() {
+ if (valor == 0) {
+ return "";
+ } else {
+ return String.valueOf(valor);
+ }
+ }
+
+
+
+}
diff --git a/jogo-oito/src/main/java/chat/gpt/JogoDosOito.java b/jogo-oito/src/main/java/chat/gpt/JogoDosOito.java
index e51dd08..4a1300e 100644
--- a/jogo-oito/src/main/java/chat/gpt/JogoDosOito.java
+++ b/jogo-oito/src/main/java/chat/gpt/JogoDosOito.java
@@ -14,8 +14,8 @@
public class JogoDosOito extends JFrame implements KeyListener {
- private int[][] tabuleiro = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 0 } };
- private JButton[][] botoes = new JButton[3][3];
+ private Tabuleiro tabuleiro;
+ private JButton[][] botoes;
private JButton botaoReiniciar;
public JogoDosOito() {
@@ -24,6 +24,9 @@ public JogoDosOito() {
setSize(300, 300);
setLayout(new GridLayout(4, 3));
+ tabuleiro = new Tabuleiro();
+ botoes = new JButton[3][3];
+
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
JButton botao = new JButton();
@@ -53,16 +56,16 @@ public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
switch (keyCode) {
case KeyEvent.VK_UP:
- mover(1, 0);
+ tabuleiro.mover(1, 0);
break;
case KeyEvent.VK_DOWN:
- mover(-1, 0);
+ tabuleiro.mover(-1, 0);
break;
case KeyEvent.VK_LEFT:
- mover(0, 1);
+ tabuleiro.mover(0, 1);
break;
case KeyEvent.VK_RIGHT:
- mover(0, -1);
+ tabuleiro.mover(0, -1);
break;
}
}
@@ -73,75 +76,16 @@ public void keyTyped(KeyEvent e) {
public void keyReleased(KeyEvent e) {
}
- private void mover(int linha, int coluna) {
- int linhaVazia = -1;
- int colunaVazia = -1;
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- if (tabuleiro[i][j] == 0) {
- linhaVazia = i;
- colunaVazia = j;
- }
- }
- }
- int novaLinha = linhaVazia + linha;
- int novaColuna = colunaVazia + coluna;
- if (novaLinha < 0 || novaLinha > 2 || novaColuna < 0 || novaColuna > 2) {
- // movimento inválido
- return;
- }
- tabuleiro[linhaVazia][colunaVazia] = tabuleiro[novaLinha][novaColuna];
- tabuleiro[novaLinha][novaColuna] = 0;
- atualizarTabuleiro();
- if (jogoConcluido()) {
- JOptionPane.showMessageDialog(this, "Parabéns, você venceu!");
- reiniciarJogo();
- }
- }
-
public static void main(String[] args) {
new JogoDosOito();
}
- private boolean jogoConcluido() {
- int count = 1;
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- if (tabuleiro[i][j] != count % 9) {
- return false;
- }
- count++;
- }
- }
- return true;
- }
-
- private boolean movimentarPeca(int linha, int coluna) {
- if (linha > 0 && tabuleiro[linha - 1][coluna] == 0) {
- tabuleiro[linha - 1][coluna] = tabuleiro[linha][coluna];
- tabuleiro[linha][coluna] = 0;
- return true;
- } else if (linha < 2 && tabuleiro[linha + 1][coluna] == 0) {
- tabuleiro[linha + 1][coluna] = tabuleiro[linha][coluna];
- tabuleiro[linha][coluna] = 0;
- return true;
- } else if (coluna > 0 && tabuleiro[linha][coluna - 1] == 0) {
- tabuleiro[linha][coluna - 1] = tabuleiro[linha][coluna];
- tabuleiro[linha][coluna] = 0;
- return true;
- } else if (coluna < 2 && tabuleiro[linha][coluna + 1] == 0) {
- tabuleiro[linha][coluna + 1] = tabuleiro[linha][coluna];
- tabuleiro[linha][coluna] = 0;
- return true;
- }
- return false;
- }
-
private void atualizarTabuleiro() {
+ int[][] estadoTabuleiro = tabuleiro.getEstado();
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
JButton botao = botoes[i][j];
- int valor = tabuleiro[i][j];
+ int valor = estadoTabuleiro[i][j];
if (valor == 0) {
botao.setText("");
} else {
@@ -152,7 +96,7 @@ private void atualizarTabuleiro() {
}
private void reiniciarJogo() {
- tabuleiro = new int[][] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 0 } };
+ tabuleiro.reiniciar();
atualizarTabuleiro();
}
-}
+}
\ No newline at end of file
diff --git a/jogo-oito/src/main/java/chat/gpt/Tabuleiro.java b/jogo-oito/src/main/java/chat/gpt/Tabuleiro.java
new file mode 100644
index 0000000..9880ea2
--- /dev/null
+++ b/jogo-oito/src/main/java/chat/gpt/Tabuleiro.java
@@ -0,0 +1,59 @@
+package chat.gpt;
+
+import javax.swing.JButton;
+import javax.swing.JOptionPane;
+
+public class Tabuleiro {
+
+ private int[][] estado;
+
+ public Tabuleiro() {
+ estado = new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 0}};
+ }
+
+ public int[][] getEstado() {
+ return estado;
+ }
+
+ public void mover(int linha, int coluna) {
+ int linhaVazia = -1;
+ int colunaVazia = -1;
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 3; j++) {
+ if (estado[i][j] == 0) {
+ linhaVazia = i;
+ colunaVazia = j;
+ }
+ }
+ }
+ int novaLinha = linhaVazia + linha;
+ int novaColuna = colunaVazia + coluna;
+ if (novaLinha < 0 || novaLinha > 2 || novaColuna < 0 || novaColuna > 2) {
+ // Movimento inválido
+ return;
+ }
+ estado[linhaVazia][colunaVazia] = estado[novaLinha][novaColuna];
+ estado[novaLinha][novaColuna] = 0;
+ if (jogoConcluido()) {
+ JOptionPane.showMessageDialog(null, "Parabéns, você venceu!");
+ reiniciar();
+ }
+ }
+
+ private boolean jogoConcluido() {
+ int count = 1;
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 3; j++) {
+ if (estado[i][j] != count % 9) {
+ return false;
+ }
+ count++;
+ }
+ }
+ return true;
+ }
+
+ void reiniciar() {
+ estado = new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 0}};
+ }
+}
diff --git a/senior-developer-challenge.iml b/senior-developer-challenge.iml
new file mode 100644
index 0000000..dac32f9
--- /dev/null
+++ b/senior-developer-challenge.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file