Created
November 8, 2018 16:38
-
-
Save edusantana/e1001f5798c63181c21da667c476548c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package urna; | |
import java.util.LinkedList; | |
import java.util.List; | |
public class Controller { | |
List<Usuario> usuarios = new LinkedList<Usuario>(); | |
public static void main(String[] args) { | |
Controller controller = new Controller(); | |
Usuario user = new Usuario("Eduardo", "1234", "senha123"); | |
controller.usuarios.add(user); | |
controller.usuarios.add(new Usuario("Jamily", "m201777", "loira")); | |
System.out.println(controller.usuarios.size()); | |
for (int i = 0; i < args.length; i++) { | |
} | |
for (Usuario usuario : controller.usuarios) { | |
System.out.println(usuario.nome); | |
} | |
String matricula = "m201777"; | |
String senhaDigita = "loira"; | |
Usuario usuarioLogado = controller.login(matricula, senhaDigita); | |
System.out.println(usuarioLogado.nome); | |
} | |
/** | |
* Retorna null se não houver susuário ou senha errada, senão retorn o usuario | |
* | |
* @param matricula | |
* @param senhaDigita | |
*/ | |
public Usuario login(String matricula, String senhaDigita) { | |
Usuario resultado = null; | |
for (Usuario usuario : usuarios) { | |
if (usuario.matricula.equals(matricula) && usuario.senha.equals(senhaDigita)) { | |
resultado = usuario; | |
} | |
} | |
return resultado; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment