Aggiunti i javadoc ai metodi e alle classi
Apportate leggeri cambiamenti alla grafica
This commit is contained in:
@@ -9,16 +9,22 @@ import java.util.GregorianCalendar;
|
|||||||
* Date: 16/12/13
|
* Date: 16/12/13
|
||||||
* Time: 18.46
|
* Time: 18.46
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Classe che rappresenta un bene di consumo all'interno del catalogo.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class BeniDiConsumo implements Utilizzabile, Serializable{
|
public class BeniDiConsumo implements Utilizzabile, Serializable{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Costruttore che inizializza i valori del bene di consumo
|
||||||
*
|
*
|
||||||
* @param idBene
|
* @param idBene
|
||||||
* @param descrizioneBene
|
* @param descrizioneBene
|
||||||
* @param prezzoBene
|
* @param prezzoBene
|
||||||
* @param beniInStock
|
* @param beniInStock
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public BeniDiConsumo ( int idBene, String descrizioneBene, double prezzoBene, int beniInStock ){
|
public BeniDiConsumo ( int idBene, String descrizioneBene, double prezzoBene, int beniInStock ){
|
||||||
this.idBene=idBene;
|
this.idBene=idBene;
|
||||||
this.descrizioneBene=descrizioneBene;
|
this.descrizioneBene=descrizioneBene;
|
||||||
@@ -34,42 +40,72 @@ public class BeniDiConsumo implements Utilizzabile, Serializable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - id bene
|
||||||
|
*/
|
||||||
public int getIdBene() {
|
public int getIdBene() {
|
||||||
return idBene;
|
return idBene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - descrizione bene
|
||||||
|
*/
|
||||||
public String getDescrizioneBene() {
|
public String getDescrizioneBene() {
|
||||||
return descrizioneBene;
|
return descrizioneBene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - prezzo del bene
|
||||||
|
*/
|
||||||
public double getPrezzoBene() {
|
public double getPrezzoBene() {
|
||||||
return prezzoBene;
|
return prezzoBene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - la quantita dei beni da vendere
|
||||||
|
*/
|
||||||
public int getBeniInStock() {
|
public int getBeniInStock() {
|
||||||
return beniInStock;
|
return beniInStock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - numero di oggetti venduti
|
||||||
|
*/
|
||||||
public int getBeniVenduti() {
|
public int getBeniVenduti() {
|
||||||
return beniVenduti;
|
return beniVenduti;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param descrizioneBene - descrizione del bene
|
||||||
|
*/
|
||||||
public void setDescrizioneBene(String descrizioneBene) {
|
public void setDescrizioneBene(String descrizioneBene) {
|
||||||
this.descrizioneBene = descrizioneBene;
|
this.descrizioneBene = descrizioneBene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param prezzoBene - prezzo del bene
|
||||||
|
*/
|
||||||
public void setPrezzoBene(double prezzoBene) {
|
public void setPrezzoBene(double prezzoBene) {
|
||||||
this.prezzoBene = prezzoBene;
|
this.prezzoBene = prezzoBene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param beniInStock - quantita' del bene disponibile per la vendita
|
||||||
|
*/
|
||||||
public void setBeniInStock(int beniInStock) {
|
public void setBeniInStock(int beniInStock) {
|
||||||
this.beniInStock = beniInStock;
|
this.beniInStock = beniInStock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - la scadenza del bene (viene considerata una data a lungo termine)
|
||||||
|
*/
|
||||||
public GregorianCalendar getScadenza() {
|
public GregorianCalendar getScadenza() {
|
||||||
return scadenza;
|
return scadenza;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Questo metodo setta i beni venduti, decrementa la quantita in magazzino e incrementa il numero di oggeti venduti
|
||||||
|
*/
|
||||||
public void setBeniVenduti() {
|
public void setBeniVenduti() {
|
||||||
beniInStock--;
|
beniInStock--;
|
||||||
beniVenduti++;
|
beniVenduti++;
|
||||||
|
|||||||
@@ -9,17 +9,23 @@ import java.util.GregorianCalendar;
|
|||||||
* Date: 16/12/13
|
* Date: 16/12/13
|
||||||
* Time: 18.47
|
* Time: 18.47
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Classe che rappresenta una cena all'interno del catalogo.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class CeneInRistoranti implements Utilizzabile, Serializable{
|
public class CeneInRistoranti implements Utilizzabile, Serializable{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param idCena
|
* @param idCena - l'id della cena
|
||||||
* @param nomeRistorante
|
* @param nomeRistorante - il ristorante in cui usufruire dell'offerta
|
||||||
* @param luogo
|
* @param luogo - Ubicazione del ristorante
|
||||||
* @param descrizione_cena
|
* @param descrizione_cena - descrizione della cena (cosa viene offerto dal ristorante)
|
||||||
* @param costoPerPersona
|
* @param costoPerPersona - costo per singola persona
|
||||||
* @param dataScadenzaOffertaCena
|
* @param dataScadenzaOffertaCena - scadenza dell'offerta
|
||||||
* @param numCenedaVendere
|
* @param numCenedaVendere - offerte disponibile per la cena
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public CeneInRistoranti(int idCena, String nomeRistorante, String luogo, String descrizione_cena, double costoPerPersona, GregorianCalendar dataScadenzaOffertaCena, int numCenedaVendere){
|
public CeneInRistoranti(int idCena, String nomeRistorante, String luogo, String descrizione_cena, double costoPerPersona, GregorianCalendar dataScadenzaOffertaCena, int numCenedaVendere){
|
||||||
@@ -39,62 +45,107 @@ public class CeneInRistoranti implements Utilizzabile, Serializable{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - l'id della cena
|
||||||
|
*/
|
||||||
public int getIdCena() {
|
public int getIdCena() {
|
||||||
return idCena;
|
return idCena;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - in nome del ristorante
|
||||||
|
*/
|
||||||
public String getNomeRistorante() {
|
public String getNomeRistorante() {
|
||||||
return nomeRistorante;
|
return nomeRistorante;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - l'ubicazione del ristorante
|
||||||
|
*/
|
||||||
public String getLuogo() {
|
public String getLuogo() {
|
||||||
return luogo;
|
return luogo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - descrizione della cena
|
||||||
|
*/
|
||||||
public String getDescrizione_cena() {
|
public String getDescrizione_cena() {
|
||||||
return descrizione_cena;
|
return descrizione_cena;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - il costo per ogni singola persona
|
||||||
|
*/
|
||||||
public double getCostoPerPersona() {
|
public double getCostoPerPersona() {
|
||||||
return costoPerPersona;
|
return costoPerPersona;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - data di scadenza dell'offerta
|
||||||
|
*/
|
||||||
public GregorianCalendar getDataScadenzaOffertaCena() {
|
public GregorianCalendar getDataScadenzaOffertaCena() {
|
||||||
return dataScadenzaOffertaCena;
|
return dataScadenzaOffertaCena;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - il numero di cene ancora disponibili per la vendita
|
||||||
|
*/
|
||||||
public int getNumCenedaVendere() {
|
public int getNumCenedaVendere() {
|
||||||
return numCenedaVendere;
|
return numCenedaVendere;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - il numero di cene vendute
|
||||||
|
*/
|
||||||
public int getCeneVendute() {
|
public int getCeneVendute() {
|
||||||
return ceneVendute;
|
return ceneVendute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param nomeRistorante - setta il nome del ristorante
|
||||||
|
*/
|
||||||
public void setNomeRistorante(String nomeRistorante) {
|
public void setNomeRistorante(String nomeRistorante) {
|
||||||
this.nomeRistorante = nomeRistorante;
|
this.nomeRistorante = nomeRistorante;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param luogo - setta il l'ubicazione del ristorante
|
||||||
|
*/
|
||||||
public void setLuogo(String luogo) {
|
public void setLuogo(String luogo) {
|
||||||
this.luogo = luogo;
|
this.luogo = luogo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param descrizione_cena - setta la descrizione della cena (Esempio: pizza margherita, patate e dolce)
|
||||||
|
*/
|
||||||
public void setDescrizione_cena(String descrizione_cena) {
|
public void setDescrizione_cena(String descrizione_cena) {
|
||||||
this.descrizione_cena = descrizione_cena;
|
this.descrizione_cena = descrizione_cena;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param costoPerPersona - setta il costo per singola persona
|
||||||
|
*/
|
||||||
public void setCostoPerPersona(double costoPerPersona) {
|
public void setCostoPerPersona(double costoPerPersona) {
|
||||||
this.costoPerPersona = costoPerPersona;
|
this.costoPerPersona = costoPerPersona;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dataScadenzaOffertaCena - setta la data di scadenza per l'offerta
|
||||||
|
*/
|
||||||
public void setDataScadenzaOffertaCena(GregorianCalendar dataScadenzaOffertaCena) {
|
public void setDataScadenzaOffertaCena(GregorianCalendar dataScadenzaOffertaCena) {
|
||||||
this.dataScadenzaOffertaCena = dataScadenzaOffertaCena;
|
this.dataScadenzaOffertaCena = dataScadenzaOffertaCena;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param numCenedaVendere - setta il numero di cene da vendere
|
||||||
|
*/
|
||||||
public void setNumCenedaVendere(int numCenedaVendere) {
|
public void setNumCenedaVendere(int numCenedaVendere) {
|
||||||
this.numCenedaVendere = numCenedaVendere;
|
this.numCenedaVendere = numCenedaVendere;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Questo metodo all'atto dell'acquisto da parte di un utente, decrementa le cene da vendere ed incrementa quelle vendute
|
||||||
|
*/
|
||||||
public void setCeneVendute()
|
public void setCeneVendute()
|
||||||
{
|
{
|
||||||
numCenedaVendere--;
|
numCenedaVendere--;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ package it.unisa.info13d.Articoli;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* I metodi statici (globali) da usare nel progetto vanno tutti in questa classe
|
* Classe che raccoglie tutti i metodi statici (globali) da usare nel progetto
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -24,10 +24,19 @@ public class Global {
|
|||||||
return general_counter;
|
return general_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Questo metodo setta il contatore generale degli id dei prodotti
|
||||||
|
*
|
||||||
|
* @param general_counter - contatore id
|
||||||
|
*/
|
||||||
public static void setGeneral_counter(int general_counter) {
|
public static void setGeneral_counter(int general_counter) {
|
||||||
Global.general_counter = general_counter;
|
Global.general_counter = general_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return il contatore generale degli id.
|
||||||
|
*/
|
||||||
public static int getGeneral_counter() {
|
public static int getGeneral_counter() {
|
||||||
return general_counter;
|
return general_counter;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,46 +36,79 @@ public class Vacanze implements Utilizzabile, Serializable{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - id del viaggio
|
||||||
|
*/
|
||||||
public int getIdViaggio() {
|
public int getIdViaggio() {
|
||||||
return idViaggio;
|
return idViaggio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - localita' del viaggio
|
||||||
|
*/
|
||||||
public String getLocalitaViaggio() {
|
public String getLocalitaViaggio() {
|
||||||
return localitaViaggio;
|
return localitaViaggio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - data di partenza
|
||||||
|
*/
|
||||||
public GregorianCalendar getDataPartenzaViaggio() {
|
public GregorianCalendar getDataPartenzaViaggio() {
|
||||||
return dataPartenzaViaggio;
|
return dataPartenzaViaggio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - data di scadenza dell'offerta
|
||||||
|
*/
|
||||||
public GregorianCalendar getScadenzaOfferta() {
|
public GregorianCalendar getScadenzaOfferta() {
|
||||||
return scadenzaOfferta;
|
return scadenzaOfferta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - il prezzo per singola persona
|
||||||
|
*/
|
||||||
public double getPrezzoPSingola() {
|
public double getPrezzoPSingola() {
|
||||||
return prezzoPSingola;
|
return prezzoPSingola;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return - il numero di viaggi venduti
|
||||||
|
*/
|
||||||
public int getViaggiVenduti() {
|
public int getViaggiVenduti() {
|
||||||
return viaggiVenduti;
|
return viaggiVenduti;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param localitaViaggio - setta la localit' del viaggio
|
||||||
|
*/
|
||||||
public void setLocalitaViaggio(String localitaViaggio) {
|
public void setLocalitaViaggio(String localitaViaggio) {
|
||||||
this.localitaViaggio = localitaViaggio;
|
this.localitaViaggio = localitaViaggio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dataPartenzaViaggio - setta la data di patenza del viaggio
|
||||||
|
*/
|
||||||
public void setDataPartenzaViaggio(GregorianCalendar dataPartenzaViaggio) {
|
public void setDataPartenzaViaggio(GregorianCalendar dataPartenzaViaggio) {
|
||||||
this.dataPartenzaViaggio = dataPartenzaViaggio;
|
this.dataPartenzaViaggio = dataPartenzaViaggio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param scadenzaOfferta - setta la data di scadenza dell'offerta della vacanza
|
||||||
|
*/
|
||||||
public void setScadenzaOfferta(GregorianCalendar scadenzaOfferta) {
|
public void setScadenzaOfferta(GregorianCalendar scadenzaOfferta) {
|
||||||
this.scadenzaOfferta = scadenzaOfferta;
|
this.scadenzaOfferta = scadenzaOfferta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param prezzoPSingola - setta il prezzo per singola persona
|
||||||
|
*/
|
||||||
public void setPrezzoPSingola(double prezzoPSingola) {
|
public void setPrezzoPSingola(double prezzoPSingola) {
|
||||||
this.prezzoPSingola = prezzoPSingola;
|
this.prezzoPSingola = prezzoPSingola;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Questo metodo incrementa, dopo ogni acquisto, il numero di viaggi venduti
|
||||||
|
*/
|
||||||
public void setViaggiVenduti()
|
public void setViaggiVenduti()
|
||||||
{
|
{
|
||||||
viaggiVenduti++;
|
viaggiVenduti++;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class AdminSession {
|
|||||||
System.out.println("5 --> Esci");
|
System.out.println("5 --> Esci");
|
||||||
|
|
||||||
String sceltaMenu;
|
String sceltaMenu;
|
||||||
System.out.print("Operazione: ");
|
System.out.print("\nOperazione: ");
|
||||||
Scanner inputData = new Scanner(System.in);
|
Scanner inputData = new Scanner(System.in);
|
||||||
sceltaMenu = inputData.nextLine();
|
sceltaMenu = inputData.nextLine();
|
||||||
//Controllo input. La scelta deve essere obbligatoriamente compresa tra 1 e 4
|
//Controllo input. La scelta deve essere obbligatoriamente compresa tra 1 e 4
|
||||||
@@ -62,6 +62,5 @@ public class AdminSession {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ import java.text.SimpleDateFormat;
|
|||||||
*/
|
*/
|
||||||
public class Catalogo{
|
public class Catalogo{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Il costruttore definisce un nuovo catalogo nel caso non sia gia presente.
|
||||||
|
* @throws FileNotFoundException
|
||||||
|
* @throws IOException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
*/
|
||||||
public Catalogo() throws FileNotFoundException,IOException,ClassNotFoundException
|
public Catalogo() throws FileNotFoundException,IOException,ClassNotFoundException
|
||||||
{
|
{
|
||||||
File f_data = new File("cat_db");
|
File f_data = new File("cat_db");
|
||||||
@@ -46,6 +52,12 @@ public class Catalogo{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Questo metodo si occupa di serializzare il catalogo (per garantire un minimo di sicurezza) e salvarlo su disco
|
||||||
|
* @throws FileNotFoundException
|
||||||
|
* @throws IOException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
*/
|
||||||
void store_data()throws FileNotFoundException,IOException,ClassNotFoundException{
|
void store_data()throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||||
File f_data = new File("cat_db");
|
File f_data = new File("cat_db");
|
||||||
ObjectOutputStream writer = new ObjectOutputStream(new FileOutputStream(f_data));
|
ObjectOutputStream writer = new ObjectOutputStream(new FileOutputStream(f_data));
|
||||||
@@ -70,6 +82,7 @@ public class Catalogo{
|
|||||||
else
|
else
|
||||||
ClientSession.showClientMenu(this,r, username);
|
ClientSession.showClientMenu(this,r, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Questo metodo permette l'inserimento di un nuovo deal all'interno del catalogo
|
* Questo metodo permette l'inserimento di un nuovo deal all'interno del catalogo
|
||||||
* @throws ParseException
|
* @throws ParseException
|
||||||
@@ -98,81 +111,69 @@ public class Catalogo{
|
|||||||
switch(sceltaMenu)
|
switch(sceltaMenu)
|
||||||
{
|
{
|
||||||
case "1":
|
case "1":
|
||||||
System.out.println("Localita: ");
|
System.out.println("---------- Nuova Offerta Vacanza ----------");
|
||||||
|
System.out.print("Localita: ");
|
||||||
String localita = inputData.nextLine();
|
String localita = inputData.nextLine();
|
||||||
|
|
||||||
System.out.println("Data Partenza (GG/MM/AAAA): ");
|
System.out.print("Data Partenza (GG/MM/AAAA): ");
|
||||||
String data = inputData.nextLine();
|
String data = inputData.nextLine();
|
||||||
String temp[];
|
String temp[];
|
||||||
String marcatore="/";
|
String marcatore="/";
|
||||||
temp = data.split(marcatore);
|
temp = data.split(marcatore);
|
||||||
GregorianCalendar dataPartenza = new GregorianCalendar((Integer.parseInt(temp[2])),(Integer.parseInt(temp[1]))-1,(Integer.parseInt(temp[0])));
|
GregorianCalendar dataPartenza = new GregorianCalendar((Integer.parseInt(temp[2])),(Integer.parseInt(temp[1]))-1,(Integer.parseInt(temp[0])));
|
||||||
/*DateFormat format = new SimpleDateFormat( "dd/MM/yyyy" );
|
|
||||||
Date date = format.parse(inputData.nextLine());
|
System.out.print("Data Scadenza offerta (GG/MM/AAAA): ");
|
||||||
GregorianCalendar dataPartenza = new GregorianCalendar();
|
|
||||||
dataPartenza.setTime(date);*/
|
|
||||||
|
|
||||||
System.out.println("Data Scadenza offerta (GG/MM/AAAA): ");
|
|
||||||
String data2 = inputData.nextLine();
|
String data2 = inputData.nextLine();
|
||||||
String temp2[];
|
String temp2[];
|
||||||
temp2 = data2.split(marcatore);
|
temp2 = data2.split(marcatore);
|
||||||
GregorianCalendar dataScad = new GregorianCalendar((Integer.parseInt(temp2[2])),(Integer.parseInt(temp2[1]))-1,(Integer.parseInt(temp2[0])));
|
GregorianCalendar dataScad = new GregorianCalendar((Integer.parseInt(temp2[2])),(Integer.parseInt(temp2[1]))-1,(Integer.parseInt(temp2[0])));
|
||||||
|
|
||||||
/*date = format.parse(inputData.nextLine());
|
System.out.print("Prezzo singola persona: ");
|
||||||
GregorianCalendar dataScadVacanza = new GregorianCalendar();
|
|
||||||
dataScadVacanza.setTime(date);*/
|
|
||||||
|
|
||||||
System.out.println("Prezzo singola persona: ");
|
|
||||||
String prezzo = inputData.nextLine();
|
String prezzo = inputData.nextLine();
|
||||||
double prezzoPSing = Double.parseDouble(prezzo);
|
double prezzoPSing = Double.parseDouble(prezzo);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
catalogoOfferte.add(new Vacanze(Global.get_next_id(), localita, dataPartenza, dataScad, prezzoPSing));
|
catalogoOfferte.add(new Vacanze(Global.get_next_id(), localita, dataPartenza, dataScad, prezzoPSing));
|
||||||
store_data();
|
store_data();
|
||||||
break;
|
break;
|
||||||
case "2":
|
case "2":
|
||||||
System.out.println("Ristorante: ");
|
System.out.println("---------- Nuova Offerta Cena ----------");
|
||||||
|
System.out.print("Ristorante: ");
|
||||||
String ristorante = inputData.nextLine();
|
String ristorante = inputData.nextLine();
|
||||||
|
|
||||||
System.out.println("Localita: ");
|
System.out.print("Localita: ");
|
||||||
String localitaCena = inputData.nextLine();
|
String localitaCena = inputData.nextLine();
|
||||||
|
|
||||||
System.out.println("Descrizione: ");
|
System.out.print("Descrizione: ");
|
||||||
String descrizioneCena = inputData.nextLine();
|
String descrizioneCena = inputData.nextLine();
|
||||||
|
|
||||||
System.out.println("Costo a Persona: ");
|
System.out.print("Costo a Persona: ");
|
||||||
String prezzoCena = inputData.nextLine();
|
String prezzoCena = inputData.nextLine();
|
||||||
double prezzoPSingCena = Double.parseDouble(prezzoCena);
|
double prezzoPSingCena = Double.parseDouble(prezzoCena);
|
||||||
|
|
||||||
System.out.println("Data Scadenza offerta (GG/MM/AAAA): ");
|
System.out.print("Data Scadenza offerta (GG/MM/AAAA): ");
|
||||||
String data3 = inputData.nextLine();
|
String data3 = inputData.nextLine();
|
||||||
String temp3[];
|
String temp3[];
|
||||||
String marcatore2="/";
|
String marcatore2="/";
|
||||||
temp3 = data3.split(marcatore2);
|
temp3 = data3.split(marcatore2);
|
||||||
GregorianCalendar dataScadCena = new GregorianCalendar((Integer.parseInt(temp3[2])),(Integer.parseInt(temp3[1]))-1,(Integer.parseInt(temp3[0])));
|
GregorianCalendar dataScadCena = new GregorianCalendar((Integer.parseInt(temp3[2])),(Integer.parseInt(temp3[1]))-1,(Integer.parseInt(temp3[0])));
|
||||||
/*DateFormat format2 = new SimpleDateFormat( "dd/MM/yyyy" );
|
|
||||||
date = format2.parse(inputData.nextLine());
|
System.out.print("Cene da Vendere: ");
|
||||||
GregorianCalendar dataScadCena = new GregorianCalendar();
|
|
||||||
dataScadCena.setTime(date);*/
|
|
||||||
|
|
||||||
System.out.println("Cene da Vendere: ");
|
|
||||||
String nCene = inputData.nextLine();
|
String nCene = inputData.nextLine();
|
||||||
int ceneDaVendere = Integer.parseInt(nCene);
|
int ceneDaVendere = Integer.parseInt(nCene);
|
||||||
|
|
||||||
|
|
||||||
catalogoOfferte.add(new CeneInRistoranti(Global.get_next_id(), ristorante, localitaCena, descrizioneCena, prezzoPSingCena, dataScadCena, ceneDaVendere));
|
catalogoOfferte.add(new CeneInRistoranti(Global.get_next_id(), ristorante, localitaCena, descrizioneCena, prezzoPSingCena, dataScadCena, ceneDaVendere));
|
||||||
store_data();
|
store_data();
|
||||||
break;
|
break;
|
||||||
case "3":
|
case "3":
|
||||||
System.out.println("Descrizione: ");
|
System.out.println("---------- Nuova Offerta Bene ----------");
|
||||||
|
System.out.print("Descrizione: ");
|
||||||
String descrizioneBene = inputData.nextLine();
|
String descrizioneBene = inputData.nextLine();
|
||||||
|
|
||||||
System.out.println("Prezzo Bene: ");
|
System.out.print("Prezzo Bene: ");
|
||||||
String prezzoBene = inputData.nextLine();
|
String prezzoBene = inputData.nextLine();
|
||||||
int prezzo_bene = Integer.parseInt(prezzoBene);
|
int prezzo_bene = Integer.parseInt(prezzoBene);
|
||||||
|
|
||||||
System.out.println("Quantita in magazzino: ");
|
System.out.print("Quantita in magazzino: ");
|
||||||
String qntMag = inputData.nextLine();
|
String qntMag = inputData.nextLine();
|
||||||
int qnt_mag = Integer.parseInt(prezzoBene);
|
int qnt_mag = Integer.parseInt(prezzoBene);
|
||||||
|
|
||||||
@@ -183,9 +184,15 @@ public class Catalogo{
|
|||||||
IdCounter.save_counter();
|
IdCounter.save_counter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Questo metodo permette la cancellazione di un prodotto dal catalogo
|
||||||
|
* @throws FileNotFoundException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
public void cancellaProdotto() throws FileNotFoundException, ClassNotFoundException, IOException
|
public void cancellaProdotto() throws FileNotFoundException, ClassNotFoundException, IOException
|
||||||
{
|
{
|
||||||
System.out.println("------ Lista Prodotti -----");
|
System.out.println("------ Lista Prodotti -----\n--");
|
||||||
for(Utilizzabile deal: catalogoOfferte)
|
for(Utilizzabile deal: catalogoOfferte)
|
||||||
{
|
{
|
||||||
if(deal instanceof Vacanze)
|
if(deal instanceof Vacanze)
|
||||||
@@ -234,6 +241,10 @@ public class Catalogo{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param a
|
||||||
|
*/
|
||||||
public void print_cat_admin (ArrayList<Utilizzabile> a){
|
public void print_cat_admin (ArrayList<Utilizzabile> a){
|
||||||
for(Utilizzabile deal: a)
|
for(Utilizzabile deal: a)
|
||||||
{
|
{
|
||||||
@@ -268,6 +279,7 @@ public class Catalogo{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void print_cat_user (ArrayList<Utilizzabile> a, String location_user_to_compare){
|
public void print_cat_user (ArrayList<Utilizzabile> a, String location_user_to_compare){
|
||||||
for(Utilizzabile deal: a)
|
for(Utilizzabile deal: a)
|
||||||
{
|
{
|
||||||
@@ -302,19 +314,24 @@ public class Catalogo{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param in - data da convertire in millisecondi
|
||||||
|
* @return - il numero in millisencodi della data passata alla funzione.
|
||||||
|
*/
|
||||||
protected long convert_calendar_to_int (GregorianCalendar in){
|
protected long convert_calendar_to_int (GregorianCalendar in){
|
||||||
return in.getTimeInMillis();
|
return in.getTimeInMillis();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Questo metodo visualizza le offerte attive del catalogo
|
* Questo metodo visualizza le offerte attive del catalogo. Viene differenziata la visualizzazione in base all'utente.
|
||||||
* @throws IOException
|
* - L'amministratore avra' la possibilita' di scegliere l'ordinamento in base dalla data di scadenza o ID prodotti
|
||||||
* @throws ClassNotFoundException
|
* - L'utente visualizzera' le offerte attive senza possibilita' di ordinamento
|
||||||
* @throws FileNotFoundException
|
*
|
||||||
|
* @param user - username utente
|
||||||
|
* @throws FileNotFoundException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void offerteAttive(String user) throws FileNotFoundException, ClassNotFoundException, IOException
|
public void offerteAttive(String user) throws FileNotFoundException, ClassNotFoundException, IOException
|
||||||
{
|
{
|
||||||
@@ -328,9 +345,11 @@ public class Catalogo{
|
|||||||
System.out.println("2 --> Ordina Per ID");
|
System.out.println("2 --> Ordina Per ID");
|
||||||
|
|
||||||
String choice;
|
String choice;
|
||||||
|
System.out.print("Scelta operazione: ");
|
||||||
choice = reader.nextLine();
|
choice = reader.nextLine();
|
||||||
for ( ; !(choice.equals("1")) && !(choice.equals("2")) ;){
|
for ( ; !(choice.equals("1")) && !(choice.equals("2")) ;){
|
||||||
System.out.println("Scelta Errata. Riprovare");
|
System.out.println("Scelta Errata. Riprovare");
|
||||||
|
System.out.print("Scelta operazione: ");
|
||||||
choice = reader.nextLine();
|
choice = reader.nextLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -761,36 +780,34 @@ public class Catalogo{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Questo metodo visualizza lo storico degli ordini effettuati dall'utente
|
* Questo metodo visualizza lo storico degli ordini effettuati dall'utente. rende possibile l'ordinamento in base alla data di scadenza o per prezzo.
|
||||||
*
|
*
|
||||||
* @param user
|
* @param user
|
||||||
* @throws FileNotFoundException
|
* @throws FileNotFoundException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void visualizzaStorico(String user) throws FileNotFoundException, ClassNotFoundException, IOException
|
public void visualizzaStorico(String user) throws FileNotFoundException, ClassNotFoundException, IOException
|
||||||
{
|
{
|
||||||
Scanner reader = new Scanner(System.in);
|
Scanner reader = new Scanner(System.in);
|
||||||
|
|
||||||
|
|
||||||
System.out.println("1 --> Ordina Per Data di Acquisto");
|
System.out.println("1 --> Ordina Per Data di Acquisto");
|
||||||
System.out.println("2 --> Ordina Per Costo Prodotto");
|
System.out.println("2 --> Ordina Per Costo Prodotto");
|
||||||
|
|
||||||
String choice;
|
String choice;
|
||||||
|
System.out.print("Opzione: ");
|
||||||
choice = reader.nextLine();
|
choice = reader.nextLine();
|
||||||
for ( ; !(choice.equals("1")) && !(choice.equals("2")) ;){
|
for ( ; !(choice.equals("1")) && !(choice.equals("2")) ;){
|
||||||
System.out.println("Scelta Errata. Riprovare");
|
System.out.println("Scelta Errata. Riprovare");
|
||||||
|
System.out.print("Opzione: ");
|
||||||
choice = reader.nextLine();
|
choice = reader.nextLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry userLogged = Access.get_user_data(user);
|
Entry userLogged = Access.get_user_data(user);
|
||||||
System.out.println("########### STORICO ###########");
|
System.out.println("---------- STORICO ----------");
|
||||||
ArrayList<StoricoItem> storico = userLogged.getStorico();
|
ArrayList<StoricoItem> storico = userLogged.getStorico();
|
||||||
|
|
||||||
if (choice.equals("1")){
|
if (choice.equals("1")){
|
||||||
|
|
||||||
|
|
||||||
class CompareDataAcquisto implements Comparator<StoricoItem> {
|
class CompareDataAcquisto implements Comparator<StoricoItem> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -799,7 +816,6 @@ public class Catalogo{
|
|||||||
if (e1.getData_acquisto().getTimeInMillis() < e2.getData_acquisto().getTimeInMillis())
|
if (e1.getData_acquisto().getTimeInMillis() < e2.getData_acquisto().getTimeInMillis())
|
||||||
return -1;
|
return -1;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -816,16 +832,11 @@ public class Catalogo{
|
|||||||
if (e1.getPrezzo() < e2.getPrezzo())
|
if (e1.getPrezzo() < e2.getPrezzo())
|
||||||
return -1;
|
return -1;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(storico,new ComparePrezzo());
|
Collections.sort(storico,new ComparePrezzo());
|
||||||
print_storico (storico);
|
print_storico (storico);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void print_storico (ArrayList<StoricoItem> in){
|
protected void print_storico (ArrayList<StoricoItem> in){
|
||||||
@@ -841,7 +852,13 @@ public class Catalogo{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visualizzaVacanza(Vacanze dealVacanza)
|
|
||||||
|
/**
|
||||||
|
* Questo metodo visualizza una vacanza, descrivendone i suoi dati.
|
||||||
|
*
|
||||||
|
* @param dealVacanza - oggetto di tipo Vacanze che rappresenta l'offerta della Vacanza da visualizzare
|
||||||
|
*/
|
||||||
|
public void visualizzaVacanza(Vacanze dealVacanza)
|
||||||
{
|
{
|
||||||
GregorianCalendar partenza = dealVacanza.getDataPartenzaViaggio();
|
GregorianCalendar partenza = dealVacanza.getDataPartenzaViaggio();
|
||||||
int giornoP = partenza.get(Calendar.DAY_OF_MONTH);
|
int giornoP = partenza.get(Calendar.DAY_OF_MONTH);
|
||||||
@@ -854,12 +871,24 @@ public class Catalogo{
|
|||||||
|
|
||||||
System.out.println("#Vacanza-"+dealVacanza.getIdViaggio()+"# Scadenza: "+giornoS+"/"+(meseS+1)+"/"+annoS+"| Localita: "+dealVacanza.getLocalitaViaggio()+"| Partenza: "+giornoP+"/"+(meseP+1)+"/"+annoP+"| Prezzo Pers. Singola: "+dealVacanza.getPrezzoPSingola()+"\n--");
|
System.out.println("#Vacanza-"+dealVacanza.getIdViaggio()+"# Scadenza: "+giornoS+"/"+(meseS+1)+"/"+annoS+"| Localita: "+dealVacanza.getLocalitaViaggio()+"| Partenza: "+giornoP+"/"+(meseP+1)+"/"+annoP+"| Prezzo Pers. Singola: "+dealVacanza.getPrezzoPSingola()+"\n--");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Questo metodo visualizza un Bene di consumo, descrivendone i suoi dati.
|
||||||
|
*
|
||||||
|
* @param dealBene - oggetto di tipo beniDiConsumo che rappresenta l'offerta del bene da visualizzare
|
||||||
|
*/
|
||||||
|
|
||||||
public void visualizzaBene(BeniDiConsumo dealBene)
|
public void visualizzaBene(BeniDiConsumo dealBene)
|
||||||
{
|
{
|
||||||
System.out.println("#Articolo-"+dealBene.getIdBene()+"# Descrizione: "+dealBene.getDescrizioneBene()+" Prezzo: "+dealBene.getPrezzoBene()+"| Quantita in magazzino: "+dealBene.getBeniInStock()+"\n--");
|
System.out.println("#Articolo-"+dealBene.getIdBene()+"# Descrizione: "+dealBene.getDescrizioneBene()+" Prezzo: "+dealBene.getPrezzoBene()+"| Quantita in magazzino: "+dealBene.getBeniInStock()+"\n--");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Questo metodo visualizza una cena, descrivendone i suoi dati.
|
||||||
|
* @param dealCena - oggetto di tipo CeneInRistoranti che rappresenta l'offerta della cena da visualizzare
|
||||||
|
*/
|
||||||
public void visualizzaCena(CeneInRistoranti dealCena)
|
public void visualizzaCena(CeneInRistoranti dealCena)
|
||||||
{
|
{
|
||||||
GregorianCalendar scadenzaCena = dealCena.getDataScadenzaOffertaCena();
|
GregorianCalendar scadenzaCena = dealCena.getDataScadenzaOffertaCena();
|
||||||
@@ -868,16 +897,17 @@ public class Catalogo{
|
|||||||
int annoSC = scadenzaCena.get(Calendar.YEAR);
|
int annoSC = scadenzaCena.get(Calendar.YEAR);
|
||||||
System.out.println("#Cena-"+dealCena.getIdCena()+"# Scadenza:"+giornoSC+"/"+(meseSC+1)+"/"+annoSC+"| Ristorante: "+dealCena.getNomeRistorante()+"| Indirizzo: "+dealCena.getLuogo()+"| Descrizione: "+dealCena.getDescrizione_cena()+"| Costo: "+dealCena.getCostoPerPersona()+"| Disponibilita:"+dealCena.getNumCenedaVendere()+"cene"+"\n--");
|
System.out.println("#Cena-"+dealCena.getIdCena()+"# Scadenza:"+giornoSC+"/"+(meseSC+1)+"/"+annoSC+"| Ristorante: "+dealCena.getNomeRistorante()+"| Indirizzo: "+dealCena.getLuogo()+"| Descrizione: "+dealCena.getDescrizione_cena()+"| Costo: "+dealCena.getCostoPerPersona()+"| Disponibilita:"+dealCena.getNumCenedaVendere()+"cene"+"\n--");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return - restituisce il catalogo delle offerte
|
||||||
|
*/
|
||||||
|
|
||||||
public ArrayList<Utilizzabile> getCatalogo() {
|
public ArrayList<Utilizzabile> getCatalogo() {
|
||||||
return catalogoOfferte;
|
return catalogoOfferte;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean testInputData()
|
|
||||||
{
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArrayList<Utilizzabile> catalogoOfferte;
|
private ArrayList<Utilizzabile> catalogoOfferte;
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class ClientSession {
|
|||||||
public static void showClientMenu(Catalogo catalogo, ReShow r, String username) throws FileNotFoundException, ClassNotFoundException, IOException {
|
public static void showClientMenu(Catalogo catalogo, ReShow r, String username) throws FileNotFoundException, ClassNotFoundException, IOException {
|
||||||
Entry loggedUser = Access.get_user_data(username);
|
Entry loggedUser = Access.get_user_data(username);
|
||||||
System.out.println("------------ Menu operazioni ------------");
|
System.out.println("------------ Menu operazioni ------------");
|
||||||
System.out.println("* Salto totale:"+loggedUser.getBalance()+" *");
|
System.out.println("-- Salto totale:"+loggedUser.getBalance());
|
||||||
System.out.println("1 --> Acquista Credito"); //Si acquista credito per l'acquisto dei prodotti
|
System.out.println("1 --> Acquista Credito"); //Si acquista credito per l'acquisto dei prodotti
|
||||||
System.out.println("2 --> Visualizza Offerte"); //Visualizza le offerte acquistabili
|
System.out.println("2 --> Visualizza Offerte"); //Visualizza le offerte acquistabili
|
||||||
System.out.println("3 --> Acquista"); //Acquisto di un offerta
|
System.out.println("3 --> Acquista"); //Acquisto di un offerta
|
||||||
@@ -60,8 +60,6 @@ public class ClientSession {
|
|||||||
case "5":
|
case "5":
|
||||||
r.reshow = false;
|
r.reshow = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ import java.util.Scanner;
|
|||||||
*/
|
*/
|
||||||
public class Access {
|
public class Access {
|
||||||
/**
|
/**
|
||||||
* Questo metodo pemette di capire se fare un Login o una Registrazione
|
* Questo metodo avvia la procedura di login o di registrazione dell'utente in base alla scelta fatta nel menu.
|
||||||
*
|
*
|
||||||
* @param set_user_logged_here dove memorizzare il nome dell'utente loggato o registrato
|
* @param set_user_logged_here dove memorizzare il nome dell'utente loggato o registrato
|
||||||
* @return false se Amministratore, true se Utente
|
* @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) throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||||
|
|
||||||
System.out.println("Benvenuto");
|
System.out.println("---------- Benvenuto ----------");
|
||||||
Scanner reader = new Scanner(System.in);
|
Scanner reader = new Scanner(System.in);
|
||||||
|
|
||||||
|
|
||||||
@@ -27,20 +27,29 @@ public class Access {
|
|||||||
System.out.println("2 --> Registrazione");
|
System.out.println("2 --> Registrazione");
|
||||||
|
|
||||||
String choice;
|
String choice;
|
||||||
|
System.out.print("\nScelta operazione: ");
|
||||||
choice = reader.nextLine();
|
choice = reader.nextLine();
|
||||||
for ( ; !(choice.equals("1")) && !(choice.equals("2")) ;){
|
for ( ; !(choice.equals("1")) && !(choice.equals("2")) ;){
|
||||||
System.out.println("Scelta Errata. Riprovare");
|
System.out.println("Scelta Errata. Riprovare");
|
||||||
|
System.out.print("\nScelta operazione: ");
|
||||||
choice = reader.nextLine();
|
choice = reader.nextLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (choice.equals("1")){
|
if (choice.equals("1")){
|
||||||
|
System.out.println("---------- Login ----------");
|
||||||
return login(set_user_logged_here);
|
return login(set_user_logged_here);
|
||||||
}
|
}
|
||||||
return register(set_user_logged_here);
|
return register(set_user_logged_here);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param set_user_logged_here - nome dell'utente loggato o registrato
|
||||||
|
* @return - Se avviene una registrazione viene restituito il valore true, poiche solo gli utenti possono registrarsi. Se viene effettuato un login, viene restituito il tipo di utente appena loggato.
|
||||||
|
* @throws FileNotFoundException
|
||||||
|
* @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) throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||||
|
|
||||||
Scanner reader = new Scanner(System.in);
|
Scanner reader = new Scanner(System.in);
|
||||||
@@ -51,7 +60,7 @@ public class Access {
|
|||||||
name = reader.nextLine();
|
name = reader.nextLine();
|
||||||
System.out.print("Password: ");
|
System.out.print("Password: ");
|
||||||
password = reader.nextLine();
|
password = reader.nextLine();
|
||||||
|
|
||||||
for (; !(search_username (name,password)) ;){
|
for (; !(search_username (name,password)) ;){
|
||||||
System.out.println("Username e/o password non trovati. Vuoi Registrarti ?: Y/N");
|
System.out.println("Username e/o password non trovati. Vuoi Registrarti ?: Y/N");
|
||||||
|
|
||||||
@@ -79,13 +88,21 @@ public class Access {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param set_user_logged_here - nome dell'utente loggato o registrato
|
||||||
|
* @return - true poiche' e' possibile la registrazione solo degli utenti.
|
||||||
|
* @throws FileNotFoundException
|
||||||
|
* @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 ) throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||||
|
|
||||||
Scanner reader = new Scanner(System.in);
|
Scanner reader = new Scanner(System.in);
|
||||||
String name;
|
String name;
|
||||||
String password;
|
String password;
|
||||||
String location;
|
String location;
|
||||||
|
System.out.println("---------- Registrazione ----------");
|
||||||
System.out.println("Inserisci i dati di Registrazione");
|
System.out.println("Inserisci i dati di Registrazione");
|
||||||
System.out.print("Username: ");
|
System.out.print("Username: ");
|
||||||
name = reader.nextLine();
|
name = reader.nextLine();
|
||||||
@@ -96,7 +113,7 @@ public class Access {
|
|||||||
|
|
||||||
|
|
||||||
store_data(name,password,location);
|
store_data(name,password,location);
|
||||||
System.out.println("Registered and Logged");
|
System.out.println("Registrato e login effettuato");
|
||||||
|
|
||||||
set_user_logged_here.logged_user = name;
|
set_user_logged_here.logged_user = name;
|
||||||
return true;
|
return true;
|
||||||
@@ -104,10 +121,11 @@ public class Access {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Questo metodo si occupa della ricerca dei dati dell'utente all'interno del "database".
|
||||||
*
|
*
|
||||||
* @param in_name
|
* @param in_name - username dell'utente
|
||||||
* @param in_password
|
* @param in_password - password dell'utente
|
||||||
* @return true if math found, false elsewhere
|
* @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{
|
protected static boolean search_username (String in_name, String in_password) throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||||
|
|
||||||
@@ -123,7 +141,6 @@ public class Access {
|
|||||||
{
|
{
|
||||||
reader.close();
|
reader.close();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
@@ -147,19 +164,18 @@ public class Access {
|
|||||||
{
|
{
|
||||||
reader.close();
|
reader.close();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Questo metodo si occupa di restituite la tipologia dell'account dell'utente connesso
|
||||||
*
|
*
|
||||||
* @param in_name
|
* @param in_name - username utente
|
||||||
* @return type of account (admin or user)
|
* @return tipo di account (admin o Client)
|
||||||
*/
|
*/
|
||||||
protected static boolean getAccountType(String in_name) throws FileNotFoundException,IOException,ClassNotFoundException{
|
protected static boolean getAccountType(String in_name) throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||||
|
|
||||||
@@ -176,22 +192,21 @@ public class Access {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* save data to user_db
|
* Questo metodo si occupa di salvare i dati su disco dell'utente.
|
||||||
*
|
*
|
||||||
* @param in_nome
|
* @param in_nome - username utente
|
||||||
* @param in_password
|
* @param in_password - password utente
|
||||||
*/
|
*/
|
||||||
protected static void store_data (String in_nome, String in_password, String in_location) throws FileNotFoundException,IOException,ClassNotFoundException{
|
protected static void store_data (String in_nome, String in_password, String in_location) throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||||
|
|
||||||
File f_data = new File("user_db");
|
File f_data = new File("user_db");
|
||||||
if ( (f_data.exists())){
|
if ( (f_data.exists())){
|
||||||
//aggiungi dati al database
|
//Aggiungi dati al database
|
||||||
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(f_data));
|
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(f_data));
|
||||||
ArrayList<Entry> database = (ArrayList<Entry>) reader.readObject();
|
ArrayList<Entry> database = (ArrayList<Entry>) reader.readObject();
|
||||||
database.add(new Entry(in_nome,in_password,true,in_location));
|
database.add(new Entry(in_nome,in_password,true,in_location));
|
||||||
@@ -200,9 +215,7 @@ public class Access {
|
|||||||
writer.writeObject(database);
|
writer.writeObject(database);
|
||||||
writer.close();
|
writer.close();
|
||||||
}else{
|
}else{
|
||||||
|
//Crea nuovo database e poi memorizza
|
||||||
//crea nuovo database e poi memorizza
|
|
||||||
|
|
||||||
ArrayList<Entry> database = new ArrayList<Entry>();
|
ArrayList<Entry> database = new ArrayList<Entry>();
|
||||||
database.add(new Entry("admin","admin",false,"UNISA"));
|
database.add(new Entry("admin","admin",false,"UNISA"));
|
||||||
database.add(new Entry(in_nome,in_password,true,in_location));
|
database.add(new Entry(in_nome,in_password,true,in_location));
|
||||||
@@ -210,12 +223,18 @@ public class Access {
|
|||||||
ObjectOutputStream writer = new ObjectOutputStream(new FileOutputStream(f_data));
|
ObjectOutputStream writer = new ObjectOutputStream(new FileOutputStream(f_data));
|
||||||
writer.writeObject(database);
|
writer.writeObject(database);
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Questo emtodo si occupa di prelevare i dati dell'utente dal disco
|
||||||
|
*
|
||||||
|
* @param in_nome - username utente
|
||||||
|
* @return un Entry contenente tutti i dati dell'utente
|
||||||
|
* @throws FileNotFoundException
|
||||||
|
* @throws IOException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
*/
|
||||||
public static Entry get_user_data (String in_nome)throws FileNotFoundException,IOException,ClassNotFoundException{
|
public static Entry get_user_data (String in_nome)throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||||
|
|
||||||
File f_data = new File("user_db");
|
File f_data = new File("user_db");
|
||||||
@@ -226,13 +245,20 @@ public class Access {
|
|||||||
{
|
{
|
||||||
reader.close();
|
reader.close();
|
||||||
return database.get(i);
|
return database.get(i);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null; // You should not be here or your database is corrupted
|
return null; // Non puoi essere qui o altriemnti il tuo database e' corrotto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Questo metodo scrive su disco le modifiche apportate agli attributi di un utente. (Ad esempio bilancio incrementato)
|
||||||
|
*
|
||||||
|
* @param in_nome - username utente
|
||||||
|
* @param new_entry - Oggetto di tipo Entry
|
||||||
|
* @throws FileNotFoundException
|
||||||
|
* @throws IOException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
*/
|
||||||
public static void replace_data (String in_nome, Entry new_entry )throws FileNotFoundException,IOException,ClassNotFoundException{
|
public static void replace_data (String in_nome, Entry new_entry )throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||||
File f_data = new File("user_db");
|
File f_data = new File("user_db");
|
||||||
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(f_data));
|
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(f_data));
|
||||||
@@ -250,5 +276,4 @@ public class Access {
|
|||||||
writer.writeObject(database);
|
writer.writeObject(database);
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,20 @@ import java.util.ArrayList;
|
|||||||
* Date: 17/12/13
|
* Date: 17/12/13
|
||||||
* Time: 0.38
|
* Time: 0.38
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Classe che rappresenta un utente all'interno del "database" su disco.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class Entry implements Serializable{
|
public class Entry implements Serializable{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Il costruttore della classe si occupa di inizializzare i dati dell'utente
|
||||||
|
* @param in_user - username utente
|
||||||
|
* @param in_password - password utente
|
||||||
|
* @param in_type - tipologia di utente
|
||||||
|
* @param in_location - luogo abitazione utente
|
||||||
|
*/
|
||||||
public Entry (String in_user, String in_password, boolean in_type, String in_location) {
|
public Entry (String in_user, String in_password, boolean in_type, String in_location) {
|
||||||
user = in_user;
|
user = in_user;
|
||||||
password = in_password;
|
password = in_password;
|
||||||
@@ -20,32 +30,60 @@ public class Entry implements Serializable{
|
|||||||
location = in_location;
|
location = in_location;
|
||||||
storico = new ArrayList<StoricoItem>();
|
storico = new ArrayList<StoricoItem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return - username of user
|
||||||
|
*/
|
||||||
public String getUser() {
|
public String getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return - password of user
|
||||||
|
*/
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return - il tipo di utente
|
||||||
|
*/
|
||||||
public boolean getType() {
|
public boolean getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return - il luogo di abitazione dell'utente
|
||||||
|
*/
|
||||||
public String getLocation() {
|
public String getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return - il saldo dell'utente
|
||||||
|
*/
|
||||||
public double getBalance() {
|
public double getBalance() {
|
||||||
return balance;
|
return balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Questo metodo aggiugne credito al saldo dell'utente.
|
||||||
|
* @param balance - valore della ricarica del saldo
|
||||||
|
*/
|
||||||
public void setBalance(double balance) {
|
public void setBalance(double balance) {
|
||||||
this.balance += balance;
|
this.balance += balance;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return - un ArrayList che rappresenta lo storico degli acquisti dell'utente
|
||||||
|
*/
|
||||||
public ArrayList<StoricoItem> getStorico() {
|
public ArrayList<StoricoItem> getStorico() {
|
||||||
return storico;
|
return storico;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ package it.unisa.info13d.Login;
|
|||||||
* User: xgiovio
|
* User: xgiovio
|
||||||
* Date: 17/12/13
|
* Date: 17/12/13
|
||||||
* Time: 1.41
|
* Time: 1.41
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Classe che rappresenta l'utente connesso al sistema.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class LoggedUser {
|
public class LoggedUser {
|
||||||
public String logged_user = "null";
|
public String logged_user = "null";
|
||||||
|
|||||||
@@ -8,34 +8,59 @@ import java.io.IOException;
|
|||||||
* User: xgiovio
|
* User: xgiovio
|
||||||
* Date: 17/12/13
|
* Date: 17/12/13
|
||||||
* Time: 1.47
|
* Time: 1.47
|
||||||
|
*
|
||||||
|
* Questa classe si occupa della gestione del login dell'utente e dell'amministratore
|
||||||
|
*
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class LoginData {
|
public class LoginData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Il costruttore si occupa di prelevare i dati dell'utente appena loggato. Tipo di account e username
|
||||||
|
*
|
||||||
|
* @throws FileNotFoundException
|
||||||
|
* @throws IOException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
*/
|
||||||
public LoginData () throws FileNotFoundException,IOException,ClassNotFoundException{
|
public LoginData () throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||||
|
|
||||||
LoggedUser logged_user = new LoggedUser();
|
LoggedUser logged_user = new LoggedUser();
|
||||||
boolean AccountType = true;
|
boolean AccountType = true;
|
||||||
AccountType = Access.get_access(logged_user);
|
AccountType = Access.get_access(logged_user); //chiama al form di login e/o registrazione
|
||||||
|
|
||||||
type = convert_type (AccountType);
|
type = convert_type (AccountType);
|
||||||
username = logged_user.logged_user;
|
username = logged_user.logged_user;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Questo metodo si occupa di convertire un valore bolleano nel tipo di account dll'utente connesso
|
||||||
|
*
|
||||||
|
* @param value - tipo di account (Admin o Client) ottenuto dalla chiamata alla funzione Access.get_access(LoggedUser set_user_logged_here)
|
||||||
|
* @return restituisce un valore booleano, che rappresenta il tipo di utente connesso, false=>Admin true=>Client
|
||||||
|
*/
|
||||||
protected String convert_type (boolean value){
|
protected String convert_type (boolean value){
|
||||||
if (value == false)
|
if (value == false)
|
||||||
return "Admin";
|
return "Admin";
|
||||||
return "Client";
|
return "Client";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return restituisce l'username dell'utente connesso
|
||||||
|
*/
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return restituisce il tipo di account associato all'utente connesso
|
||||||
|
*/
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stampa le informazioni dell'utente connesso (username e tipo di account)
|
||||||
|
*/
|
||||||
public void getUserDataInfo (){
|
public void getUserDataInfo (){
|
||||||
|
|
||||||
System.out.println("\n***************************************");
|
System.out.println("\n***************************************");
|
||||||
|
|||||||
@@ -14,7 +14,13 @@ import java.util.GregorianCalendar;
|
|||||||
* Questa classe rappresenta un singolo acquisto fatto dall'utente.
|
* Questa classe rappresenta un singolo acquisto fatto dall'utente.
|
||||||
*/
|
*/
|
||||||
public class StoricoItem implements Serializable {
|
public class StoricoItem implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param in_description - descrizione articolo acquistato
|
||||||
|
* @param in_data_acquisto - data dell'acquisto (Generata al momento dell'acquisto)
|
||||||
|
* @param in_prezzo - prezzo dell'articolo
|
||||||
|
*/
|
||||||
public StoricoItem (String in_description, GregorianCalendar in_data_acquisto, double in_prezzo){
|
public StoricoItem (String in_description, GregorianCalendar in_data_acquisto, double in_prezzo){
|
||||||
description = in_description;
|
description = in_description;
|
||||||
data_acquisto = in_data_acquisto;
|
data_acquisto = in_data_acquisto;
|
||||||
@@ -22,15 +28,25 @@ public class StoricoItem implements Serializable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return - descrizione deall'articolo acquistato
|
||||||
|
*/
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return - la data dell'acquisto dell'oggeto
|
||||||
|
*/
|
||||||
public GregorianCalendar getData_acquisto() {
|
public GregorianCalendar getData_acquisto() {
|
||||||
return data_acquisto;
|
return data_acquisto;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return - il prezzo dell'oggetto acquistato
|
||||||
|
*/
|
||||||
public double getPrezzo() {
|
public double getPrezzo() {
|
||||||
return prezzo;
|
return prezzo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,12 @@ import java.text.ParseException;
|
|||||||
|
|
||||||
import it.unisa.info13d.Utility.IdCounter;
|
import it.unisa.info13d.Utility.IdCounter;
|
||||||
import it.unisa.info13d.Utility.ReShow;
|
import it.unisa.info13d.Utility.ReShow;
|
||||||
|
/**
|
||||||
|
* Questa classe rappresenta il Main dell'applicazione dalla quale si avvieranno le procedure per la gestione dell'utente e del catalogo.
|
||||||
|
*
|
||||||
|
* @author Simone Argenziano e Giovanni Di Grezia
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) throws FileNotFoundException,IOException,ClassNotFoundException, ParseException {
|
public static void main(String[] args) throws FileNotFoundException,IOException,ClassNotFoundException, ParseException {
|
||||||
@@ -19,17 +24,11 @@ public class Main {
|
|||||||
LoginData login = new LoginData();
|
LoginData login = new LoginData();
|
||||||
login.getUserDataInfo();
|
login.getUserDataInfo();
|
||||||
|
|
||||||
|
|
||||||
IdCounter.restore_counter();
|
IdCounter.restore_counter();
|
||||||
Catalogo load_catalogo = new Catalogo();
|
Catalogo load_catalogo = new Catalogo();
|
||||||
|
|
||||||
|
|
||||||
ReShow r = new ReShow();
|
ReShow r = new ReShow();
|
||||||
for (;r.reshow;)
|
for (;r.reshow;)
|
||||||
load_catalogo.showMenu(login.getType(),login.getUsername(),r);
|
load_catalogo.showMenu(login.getType(),login.getUsername(),r);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,21 @@ import java.util.ArrayList;
|
|||||||
* Date: 18/12/13
|
* Date: 18/12/13
|
||||||
* Time: 00:41
|
* Time: 00:41
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Classe che rappresenta il contatore generale dell'id di ogni articolo presente in catalogo
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class IdCounter {
|
public class IdCounter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Questo metodo salva il contatore dell'id sul disco.
|
||||||
|
* @throws FileNotFoundException
|
||||||
|
* @throws IOException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
*/
|
||||||
public static void save_counter() throws FileNotFoundException,IOException,ClassNotFoundException{
|
public static void save_counter() throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||||
File f_data = new File("id_counter");
|
File f_data = new File("id_counter");
|
||||||
Integer data = Integer.valueOf(Global.getGeneral_counter());
|
Integer data = Integer.valueOf(Global.getGeneral_counter());
|
||||||
@@ -23,6 +36,13 @@ public class IdCounter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Questo metodo legge il valore del contatore e lo setta.
|
||||||
|
*
|
||||||
|
* @throws FileNotFoundException
|
||||||
|
* @throws IOException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
*/
|
||||||
public static void restore_counter() throws FileNotFoundException,IOException,ClassNotFoundException{
|
public static void restore_counter() throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||||
File f_data = new File("id_counter");
|
File f_data = new File("id_counter");
|
||||||
if ( (f_data.exists())){
|
if ( (f_data.exists())){
|
||||||
@@ -32,10 +52,6 @@ public class IdCounter {
|
|||||||
}else{
|
}else{
|
||||||
|
|
||||||
Global.setGeneral_counter(0);
|
Global.setGeneral_counter(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user