Esempio n. 1
0
  /** menu login */
  private void menu() {

    int option = 0;
    Scanner read = new Scanner(System.in);
    while (true) {
      try {
        String email = "";
        System.out.println(
            "\n -----< MyBet-and-Win >-----\n\nSelect an Option: \n"
                + "(1)-Register;\n(2)-Login;\n(3)-Exit;\n\n>");
        // lê opção do teclado
        // ---------------------------
        InputStreamReader input0 = new InputStreamReader(System.in);
        BufferedReader reader0 = new BufferedReader(input0);
        String op;

        op = reader0.readLine();

        option = Integer.parseInt(op);

        switch (option) {
            // PASSWORD
          case 1:
            System.out.println("=================|Registo|===================");
            System.out.println("Introduza o username a registar:\n> ");
            String username = reader0.readLine();
            System.out.println("Password: \n> ");
            String password = reader0.readLine();
            System.out.println("Email: \n> ");
            email = reader0.readLine();
            Register reg = new Register(username, password, email);
            server.register(reg);
            break;
          case 2:
            System.out.println("=================|Login|===================");
            System.out.println("Introduza o username para fazer o Login:\n> ");
            String user = reader0.readLine();
            System.out.println("Password: \n> ");
            String pass = reader0.readLine();

            Login log = new Login(user, pass);

            User player = new User(user, pass);
            player.setCredit(100);

            if (server.login(log, player, (ClientInterface) this)) {
              this.init((ClientInterface) this, user);
              showMenu(user, pass, player);
            } else
              System.out.println(
                  "Falhou autenticação. User já logado ou Username e/ou passowrd incorrectas introduza os dados novamente:");
            break;
        }
      } catch (IOException ex) {
        Logger.getLogger(ClientRMI.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
  }