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
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>TesteProjeto</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.8.0</version>
</dependency>

</dependencies>

<properties>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>
76 changes: 76 additions & 0 deletions src/main/java/menuclasses/AdicionaCandidato.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package menuclasses;

import org.run.Main;
import utilities.*;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class AdicionaCandidato {
ContadorDeFormularios contador = new ContadorDeFormularios();
PadronizadorDeTexto padronizador = new PadronizadorDeTexto();
MapeadorDePerguntas mapeador = new MapeadorDePerguntas();
String retornoEmString = contador.contadorDeArquivos();
String caminhoFormulario = "C:\\Go\\src\\github.com\\java-testes-2022\\src\\main\\java\\org\\run\\formulario.txt";
String caminhoModels = "C:\\Go\\src\\github.com\\java-testes-2022\\src\\main\\java\\models\\";



public void candidatar() throws IOException {

Map <Integer, String> mapaDePerguntas = new HashMap<>();
Map<Integer, String> mapaDeRespostas = new HashMap<>();

Scanner scannerLeitorDePerguntas = new Scanner(new File(caminhoFormulario));
Scanner scannerCapturaResposta = new Scanner(System.in);

while (scannerLeitorDePerguntas.hasNextLine()){
String linhaPergunta = scannerLeitorDePerguntas.nextLine();
if (!linhaPergunta.isEmpty()){
Integer numeroDaPergunta = mapeador.obterNumeroDaPergunta(linhaPergunta);
String pergunta = mapeador.obterTextoPergunta(linhaPergunta);
mapaDePerguntas.put(numeroDaPergunta, pergunta);
}
}

//For each e cria��o do MAPA para ler cada linha do TXT de perguntas e respostas.
mapaDePerguntas.forEach((k,v)-> {
System.out.println(v);
String resposta = scannerCapturaResposta.nextLine();
if (k.equals(3) && Integer.parseInt(resposta) < 16) {
String respostaIdade;
do {
System.out.println("Idade Incorreta Preencha Novamente");
respostaIdade = scannerCapturaResposta.nextLine();
} while (Integer.parseInt(respostaIdade) < 16);
resposta = respostaIdade;
}
mapaDeRespostas.put(k, resposta);
});
// Cria o nome padr�o pro arquivo e gera o txt.
String nomeDoArquivo = retornoEmString + " - " + padronizador.padronizadorDeTexto(mapaDeRespostas.get(1)) + ".txt";
PrintWriter gravadorDeTXT = new PrintWriter(caminhoModels + nomeDoArquivo, "UTF-8");

//Adiciona o conte�do ao txt do candidato.
List<String> respostasCandidato = mapaDeRespostas.values().stream().toList();
StringBuilder formatadorDaListaAparaGravar = new StringBuilder();
respostasCandidato.forEach(x -> {
formatadorDaListaAparaGravar.append(x+"\n");
});
gravadorDeTXT.print(formatadorDaListaAparaGravar);

//Fecha os scanners e chama o menu principal

gravadorDeTXT.close();
scannerCapturaResposta.close();
scannerLeitorDePerguntas.close();
Main.chamarMenuPrincipal();

}

}
59 changes: 59 additions & 0 deletions src/main/java/menuclasses/AdicionaPergunta.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package menuclasses;

import org.run.Main;
import utilities.MapeadorDePerguntas;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import utilities.*;

public class AdicionaPergunta {
RemoveEspacos removedor = new RemoveEspacos();
MapeadorDePerguntas mapeador = new MapeadorDePerguntas();
String caminhoFormulario = "C:\\Go\\src\\github.com\\java-testes-2022\\src\\main\\java\\org\\run\\formulario.txt";
public void adicionar() throws IOException {

Map<Integer, String> mapaDePerguntasAtuais = new HashMap<>();

// Sobrescreverá o texto
BufferedWriter sobrescritorDeTexto = new BufferedWriter(new FileWriter(caminhoFormulario, true));
// Vai ler as perguntas
Scanner leitorPerguntasAtuais = new Scanner(new File(caminhoFormulario));
// Vai pedir a nova pergunta
Scanner novaPergunta = new Scanner(System.in);


//Passar pelo arquivo e gravar todas perguntas para conferir se tem igual
while (leitorPerguntasAtuais.hasNextLine()){
String linhaPergunta = leitorPerguntasAtuais.nextLine();
Integer numeroDaPergunta = mapeador.obterNumeroDaPergunta(linhaPergunta);
String pergunta = mapeador.obterTextoPergunta(linhaPergunta);
mapaDePerguntasAtuais.put(numeroDaPergunta, pergunta);
}

System.out.println("Digite a nova pergunta:");
String novaPerguntaEscrita = novaPergunta.nextLine();

if (mapaDePerguntasAtuais.containsValue(novaPerguntaEscrita)) {
System.out.println("Não é possível adicionar a mesma pergunta.");
return ;
} else {
int idDaPerguntaNova = mapaDePerguntasAtuais.size() + 1;
sobrescritorDeTexto.append("\n"+"P" + idDaPerguntaNova + "|" + novaPerguntaEscrita);
System.out.println("Pergunta Adicionada com sucesso");
}

sobrescritorDeTexto.close();
leitorPerguntasAtuais.close();
novaPergunta.close();

removedor.removerLinhasEmBranco();
Main.chamarMenuPrincipal();
}
}

59 changes: 59 additions & 0 deletions src/main/java/menuclasses/ListaDeCandidatos.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package menuclasses;

import org.run.Main;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;

public class ListaDeCandidatos {
String caminhoModels = "C:\\Go\\src\\github.com\\java-testes-2022\\src\\main\\java\\models\\";

public void listarCandidatos() throws IOException {

File diretorioDeTodosFormularios = new File(caminhoModels);
List<List<String>> listaComTodosFormularios = new ArrayList<>();
File [] superLista = diretorioDeTodosFormularios.listFiles();

for (File arquivo : superLista) {
BufferedReader br = new BufferedReader(new FileReader(diretorioDeTodosFormularios +"/"+ arquivo.getName()));
List<String> lista = new ArrayList<>();
String linha = "";
while (linha != null) {
linha = br.readLine();
if (linha != null && !linha.equals("")) {
lista.add(linha);
}
}
listaComTodosFormularios.add(lista);
br.close();
}

Scanner opcao = new Scanner(System.in);

System.out.println("Digite 1 para listar candidatos agrupados por idade ou 2 para listar cada candidato e sua idade");
int escolha = opcao.nextInt();

switch (escolha){
case 1:
System.out.println("Candidatos agrupados por idade");
listaComTodosFormularios.sort(Comparator.comparing(idade2 -> idade2.get(2)));
System.out.println("Idade | Nomes");
listaComTodosFormularios.forEach(nome -> System.out.println(nome.get(2) + " | " + nome.get(0)));
break;

case 2:
listaComTodosFormularios.sort(Comparator.comparing(idade2 -> idade2.get(2)));
System.out.println("Nome | Idade");
listaComTodosFormularios.forEach(nome -> System.out.println(nome.get(0) + " | " + nome.get(2)));
break;
}
opcao.close();
Main.chamarMenuPrincipal();
}
}



58 changes: 58 additions & 0 deletions src/main/java/menuclasses/PesquisaCandidato.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package menuclasses;

import org.run.Main;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.TreeMap;

public class PesquisaCandidato {
String caminhoModels = "C:\\Go\\src\\github.com\\java-testes-2022\\src\\main\\java\\models\\";

TreeMap<String,String> listaComNomeeEmail = new TreeMap<>();
public void pesquisar() throws IOException {

File diretorioDeTodosFormularios = new File(caminhoModels);

File [] superLista = diretorioDeTodosFormularios.listFiles();

for (File arquivo : superLista) {
BufferedReader br = new BufferedReader(new FileReader(diretorioDeTodosFormularios +"/"+ arquivo.getName()));
String linha = "";
List<String> lista = new ArrayList<>();

while (linha != null) {
linha = br.readLine();
if (linha != null && !linha.equals("")) {
lista.add(linha.toLowerCase());
}
}
listaComNomeeEmail.put(lista.get(0),lista.get(1));

br.close();
}

Scanner textoPesquisa = new Scanner(System.in);

listaComNomeeEmail.forEach((k, v) -> System.out.println("Key : " + k + ", Value : " + v));

System.out.println("Digite aqui o Nome do candidato (com letras minúsculas) que deseja procurar:");
String pesquisadorDeNomeFormularios = textoPesquisa.nextLine();

System.out.println("Digite aqui o Email do candidato que deseja procurar:");
String pesquisadorDeEmailFormularios = textoPesquisa.nextLine();

listaComNomeeEmail.forEach((k, v) -> {
if (k.equals(pesquisadorDeNomeFormularios) && v.equals(pesquisadorDeEmailFormularios)) {
System.out.println("Key : " + k + ", Value : " + v);}
});

textoPesquisa.close();
Main.chamarMenuPrincipal();
}
}
Loading