Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ArrayList <UserInfo> InfoList = new ArrayList<UserInfo> ();
- public void userInternalDatabase (UserInfo info)
- {
- this.user = info.user;
- this.pass = info.pass;
- this.secretCode = info.secretCode;
- }
- public void addUser(String i, String j, String k)
- {
- UserInfo newUser = new UserInfo();
- newUser.user = i;
- newUser.pass = j;
- newUser.secretCode = k;
- InfoList.add(newUser);
- }
- public Object findUsername(String a)
- {
- for (int i=0; i <InfoList.size(); i++)
- {
- if (InfoList.get(i).user.equals(a))
- {
- return "This user already exists in our database.";
- }
- }
- return "NÃO EXISTE ESSE UTILIZADOR.";
- }
- }
- class DadosGuardados
- {
- private static int lerNumero(Scanner kb, String mensagem, String mensagemErro)
- {
- while (true)
- {
- System.out.println(mensagem);
- try
- {
- return Integer.parseInt(kb.nextLine());
- }
- catch (NumberFormatException e)
- {
- System.out.println(mensagemErro);
- }
- }
- }
- private static boolean lerSimNao(Scanner kb, String mensagem, String mensagemErro)
- {
- while (true)
- {
- System.out.println(mensagem);
- String x = kb.nextLine();
- if (x.equalsIgnoreCase("S")) return true;
- if (x.equalsIgnoreCase("N")) return false;
- System.out.println(mensagemErro);
- }
- }
- public static void main(String[] args)
- {
- Scanner kb = new Scanner(System.in);
- System.out.println("Bem-vindo, utilizador.");
- boolean maisRecarga = true;
- while (maisRecarga)
- {
- int recarga = lerNumero(kb, "Introduza o número da recarga: ", "Isso que você digitou não era um número. Por favor, tente novamente.");
- System.out.println("Você digitou " + recarga + ".");
- maisRecarga = lerSimNao(kb, "Tem mais recarga para registar?nResponda `S´ para continuar ou `N´ para terminar: ", "Era para você responder S ou N! Por favor, tente novamente.");
- }
- System.out.println("Obrigado, até o próximo registro.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement