Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package app;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- int cantidad = 1;
- boolean rta = false;
- Scanner scanner = new Scanner(System.in);
- while (!rta)
- {
- try
- {
- System.out.println("ingrese usuario");
- rta = login(scanner.nextLine(),"1223",cantidad);
- }
- catch (UsuarioIncorrecto ex)
- {
- //inicio flujo de olvide mi usuario
- cantidad++;
- }
- catch (PasswordIncorrecto e) {
- // TODO: handle exception
- //inicio flujo de olvide contraseña
- cantidad++;
- }
- catch (Exception e) {
- // TODO Auto-generated catch block
- System.out.println(e.getMessage());
- }
- }
- //login2("pepe", "1234");
- }
- public static boolean login(String usuario, String pass, int cantidad)
- throws UsuarioIncorrecto, PasswordIncorrecto
- {
- if (!usuario.equals("admin"))
- {
- throw new UsuarioIncorrecto("no sos admin",cantidad);
- }
- if (!pass.equals("123"))
- {
- throw new PasswordIncorrecto("mal la contraseña");
- }
- return true;
- }
- public static void login2(String usuario, String pass)
- {
- try
- {
- if (!usuario.equals("admin"))
- {
- throw new Exception("no sos admin");
- }
- }
- catch (Exception e) {
- System.out.println(e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement