Merge branch 'master' of bitbucket.org:xgiovio/unisa_project_java_fist
This commit is contained in:
@@ -771,19 +771,75 @@ public class Catalogo{
|
|||||||
|
|
||||||
public void visualizzaStorico(String user) throws FileNotFoundException, ClassNotFoundException, IOException
|
public void visualizzaStorico(String user) throws FileNotFoundException, ClassNotFoundException, IOException
|
||||||
{
|
{
|
||||||
Entry userLogged = Access.get_user_data(user);
|
Scanner reader = new Scanner(System.in);
|
||||||
System.out.println("########### STORICO ###########");
|
|
||||||
ArrayList<StoricoItem> storico = userLogged.getStorico();
|
|
||||||
for(StoricoItem record: storico)
|
System.out.println("1 --> Ordina Per Data di Acquisto");
|
||||||
{
|
System.out.println("2 --> Ordina Per Costo Prodotto");
|
||||||
GregorianCalendar partenza = record.getData_acquisto();
|
|
||||||
int giornoP = partenza.get(Calendar.DAY_OF_MONTH);
|
String choice;
|
||||||
int meseP = partenza.get(Calendar.MONTH);
|
choice = reader.nextLine();
|
||||||
int annoP = partenza.get(Calendar.YEAR);
|
for ( ; !(choice.equals("1")) && !(choice.equals("2")) ;){
|
||||||
System.out.println("| deal: "+record.getDescription()+"| Data Acquisto: "+giornoP+"/"+(meseP+1)+"/"+annoP+"| Prezzo: "+record.getPrezzo());
|
System.out.println("Scelta Errata. Riprovare");
|
||||||
}
|
choice = reader.nextLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
Entry userLogged = Access.get_user_data(user);
|
||||||
|
System.out.println("########### STORICO ###########");
|
||||||
|
ArrayList<StoricoItem> storico = userLogged.getStorico();
|
||||||
|
|
||||||
|
if (choice.equals("1")){
|
||||||
|
|
||||||
|
|
||||||
|
class CompareDataAcquisto implements Comparator<StoricoItem> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(StoricoItem e1, StoricoItem e2) {
|
||||||
|
|
||||||
|
if (e1.getData_acquisto().getTimeInMillis() < e2.getData_acquisto().getTimeInMillis())
|
||||||
|
return -1;
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort(storico,new CompareDataAcquisto());
|
||||||
|
print_storico(storico);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
class ComparePrezzo implements Comparator<StoricoItem> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(StoricoItem e1, StoricoItem e2) {
|
||||||
|
|
||||||
|
if (e1.getPrezzo() < e2.getPrezzo())
|
||||||
|
return -1;
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort(storico,new ComparePrezzo());
|
||||||
|
print_storico (storico);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void print_storico (ArrayList<StoricoItem> in){
|
||||||
|
|
||||||
|
for(StoricoItem record: in)
|
||||||
|
{
|
||||||
|
GregorianCalendar partenza = record.getData_acquisto();
|
||||||
|
int giornoP = partenza.get(Calendar.DAY_OF_MONTH);
|
||||||
|
int meseP = partenza.get(Calendar.MONTH);
|
||||||
|
int annoP = partenza.get(Calendar.YEAR);
|
||||||
|
System.out.println("| deal: "+record.getDescription()+"| Data Acquisto: "+giornoP+"/"+(meseP+1)+"/"+annoP+"| Prezzo: "+record.getPrezzo());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void visualizzaVacanza(Vacanze dealVacanza)
|
public void visualizzaVacanza(Vacanze dealVacanza)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user