Prima Versione dell'accesso al sistema. Sistema ancora incompleto. Simone prova gia ad eseguirlo come sta, fammi sapere se ti piace. I dati di registrazione e login chiaramente non ci sono ancora ma almeno hai una idea del funzionamento.
This commit is contained in:
153
it/unisa/info13d/Login/Access.java
Normal file
153
it/unisa/info13d/Login/Access.java
Normal file
@@ -0,0 +1,153 @@
|
||||
package it.unisa.info13d.Login;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* Created with MONSTER.
|
||||
* User: xgiovio
|
||||
* Date: 16/12/13
|
||||
* Time: 19.45
|
||||
*/
|
||||
public class Access {
|
||||
/**
|
||||
* Questo metodo pemette di capire se fare un Login o una Registrazione
|
||||
*
|
||||
* @param set_user_logged_here dove memorizzare il nome dell'utente loggato o registrato
|
||||
* @return false se Amministratore, true se Utente
|
||||
*/
|
||||
public static boolean get_access (String set_user_logged_here){
|
||||
|
||||
System.out.println("Benvenuto");
|
||||
Scanner reader = new Scanner(System.in);
|
||||
|
||||
|
||||
System.out.println("1 --> Login");
|
||||
System.out.println("2 --> Registrazione");
|
||||
|
||||
String choice;
|
||||
choice = reader.nextLine();
|
||||
for ( ; !(choice.equals("1")) && !(choice.equals("2")) ;){
|
||||
System.out.println("Scelta Errata. Riprovare");
|
||||
choice = reader.nextLine();
|
||||
}
|
||||
|
||||
if (choice.equals("1")){
|
||||
return login(set_user_logged_here);
|
||||
}
|
||||
return register(set_user_logged_here);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected static boolean login(String set_user_logged_here){
|
||||
|
||||
Scanner reader = new Scanner(System.in);
|
||||
String name;
|
||||
String password;
|
||||
|
||||
System.out.print("Username: ");
|
||||
name = reader.nextLine();
|
||||
System.out.print("Password: ");
|
||||
password = reader.nextLine();
|
||||
|
||||
for (; !(search_username (name,password)) ;){
|
||||
System.out.println("Dati non trovati. Vuoi Registrarti ?: Y/N");
|
||||
|
||||
String choice;
|
||||
choice = reader.nextLine();
|
||||
for ( ; !(choice.equals("Y")) && !(choice.equals("N")) ;){
|
||||
System.out.println("Scelta Errata. Riprovare");
|
||||
choice = reader.nextLine();
|
||||
}
|
||||
|
||||
if (choice.equals("Y")){
|
||||
return register(set_user_logged_here);
|
||||
}
|
||||
System.out.println("Reinserisci i dati di Login ");
|
||||
|
||||
System.out.print("Username: ");
|
||||
name = reader.nextLine();
|
||||
System.out.print("Password: ");
|
||||
password = reader.nextLine();
|
||||
}
|
||||
|
||||
set_user_logged_here = name;
|
||||
return getAccountType(name);
|
||||
|
||||
}
|
||||
|
||||
protected static boolean register( String set_user_logged_here ){
|
||||
|
||||
Scanner reader = new Scanner(System.in);
|
||||
String name;
|
||||
String password;
|
||||
|
||||
System.out.println("Inserisci i dati di Registrazione");
|
||||
System.out.print("Username: ");
|
||||
name = reader.nextLine();
|
||||
System.out.print("Password: ");
|
||||
password = reader.nextLine();
|
||||
|
||||
store_data(name,password);
|
||||
System.out.println("Registered and Logged");
|
||||
|
||||
set_user_logged_here = name;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param in_name
|
||||
* @param in_password
|
||||
* @return true if math found, false elsewhere
|
||||
*/
|
||||
protected static boolean search_username (String in_name, String in_password){
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param in_name
|
||||
* @return type of account (admin or user)
|
||||
*/
|
||||
protected static boolean getAccountType(String in_name){
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* save data to user_db
|
||||
*
|
||||
* @param in_nome
|
||||
* @param in_password
|
||||
*/
|
||||
protected static void store_data (String in_nome, String in_password){
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
package it.unisa.info13d;
|
||||
|
||||
import it.unisa.info13d.Login.Access;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
String logged_user = "null";
|
||||
Access.get_access(logged_user);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user