Implementato il Login/Registrazione via GUI. Quasi completato la GUI lato utente. Manca la visualizzazione degli articoli con e senza scadenza con limiti (implementati ma senza actionlistner) e il visualizzo storico.

Da fixare anche il comparatore tra oggetti per la visualizzazione ordinata, bisogna aggiungere la classa prestazioni dopera.
This commit is contained in:
2014-01-20 03:35:35 +01:00
parent e6361620a2
commit 92a0837b1c
14 changed files with 991 additions and 189 deletions

View File

@@ -17,29 +17,12 @@ public class Access {
* @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 (LoggedUser set_user_logged_here) throws FileNotFoundException,IOException,ClassNotFoundException{
public static boolean get_access (LoggedUser set_user_logged_here, String in_name,String in_password,String in_location,boolean in_action) throws FileNotFoundException,IOException,ClassNotFoundException{
System.out.println("---------- Benvenuto ----------");
Scanner reader = new Scanner(System.in);
System.out.println("1 --> Login");
System.out.println("2 --> Registrazione");
String choice;
System.out.print("\nScelta operazione: ");
choice = reader.nextLine();
for ( ; !(choice.equals("1")) && !(choice.equals("2")) ;){
System.out.println("Scelta Errata. Riprovare");
System.out.print("\nScelta operazione: ");
choice = reader.nextLine();
if (in_action == false){
return login(set_user_logged_here,in_name,in_password);
}
if (choice.equals("1")){
System.out.println("---------- Login ----------");
return login(set_user_logged_here);
}
return register(set_user_logged_here);
return register(set_user_logged_here,in_name,in_password,in_location);
}
/**
@@ -50,40 +33,16 @@ public class Access {
* @throws IOException
* @throws ClassNotFoundException
*/
protected static boolean login(LoggedUser set_user_logged_here) throws FileNotFoundException,IOException,ClassNotFoundException{
protected static boolean login(LoggedUser set_user_logged_here, String in_name,String in_password) throws FileNotFoundException,IOException,ClassNotFoundException{
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("Username e/o password 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();
}
name = in_name;
password = in_password;
set_user_logged_here.logged_user = name;
System.out.println("Logged");
return getAccountType(name);
}
@@ -96,24 +55,14 @@ public class Access {
* @throws IOException
* @throws ClassNotFoundException
*/
protected static boolean register ( LoggedUser set_user_logged_here ) throws FileNotFoundException,IOException,ClassNotFoundException{
protected static boolean register ( LoggedUser set_user_logged_here, String in_name,String in_password,String in_location ) throws FileNotFoundException,IOException,ClassNotFoundException{
Scanner reader = new Scanner(System.in);
String name;
String password;
String location;
System.out.println("---------- Registrazione ----------");
System.out.println("Inserisci i dati di Registrazione");
System.out.print("Username: ");
name = reader.nextLine();
System.out.print("Password: ");
password = reader.nextLine();
System.out.print("Location: ");
location = reader.nextLine();
String name = in_name;
String password = in_password;
String location = in_location;
store_data(name,password,location);
System.out.println("Registrato e login effettuato");
set_user_logged_here.logged_user = name;
return true;
@@ -127,7 +76,7 @@ public class Access {
* @param in_password - password dell'utente
* @return true se la ricerca ha avuto esito, false altrimenti
*/
protected static boolean search_username (String in_name, String in_password) throws FileNotFoundException,IOException,ClassNotFoundException{
public static boolean search_username (String in_name, String in_password) throws FileNotFoundException,IOException,ClassNotFoundException{
File f_data = new File("user_db");
if ( (f_data.exists())){