Implementati i metodi nuovoProdotto() - offerteAttive()
This commit is contained in:
@@ -3,6 +3,9 @@ package it.unisa.info13d.GestioneCatalogo;
|
||||
import it.unisa.info13d.Articoli.Utilizzabile;
|
||||
import it.unisa.info13d.Utility.ReShow;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
@@ -16,8 +19,12 @@ public class AdminSession {
|
||||
|
||||
/**
|
||||
* Questo metodo visualizza il menu per gli Amministratori
|
||||
* @throws IOException
|
||||
* @throws ParseException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public static void showAdminMenu(Catalogo catalogo, ReShow r) {
|
||||
public static void showAdminMenu(Catalogo catalogo, ReShow r) throws FileNotFoundException, ClassNotFoundException, ParseException, IOException {
|
||||
System.out.println("------------ Admin Menu ------------");
|
||||
System.out.println("1 --> Nuovo Prodotto"); //Inserisce un nuovo prodotto in vendita nel catalogo
|
||||
System.out.println("2 --> Cancella Prodotto"); //Cancella un prodotto in offerta nel catalogo
|
||||
@@ -39,7 +46,7 @@ public class AdminSession {
|
||||
switch(sceltaMenu)
|
||||
{
|
||||
case "1":
|
||||
catalogo.nuovoProdotto();
|
||||
catalogo.nuovoProdotto();
|
||||
break;
|
||||
case "2":
|
||||
catalogo.cancellaProdotto();
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
package it.unisa.info13d.GestioneCatalogo;
|
||||
|
||||
import it.unisa.info13d.Articoli.BeniDiConsumo;
|
||||
import it.unisa.info13d.Articoli.CeneInRistoranti;
|
||||
import it.unisa.info13d.Articoli.Global;
|
||||
import it.unisa.info13d.Articoli.Utilizzabile;
|
||||
import it.unisa.info13d.Login.Entry;
|
||||
import it.unisa.info13d.Articoli.Vacanze;
|
||||
import it.unisa.info13d.Utility.ReShow;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Scanner;
|
||||
/**
|
||||
* Created with PC-STATION.
|
||||
@@ -40,37 +54,183 @@ public class Catalogo{
|
||||
* Questo metodo seleziona in Menu da visualizzare in base al login effettuato dall'utente
|
||||
*
|
||||
* @param userType is the type of user obtained from the main
|
||||
* @throws IOException
|
||||
* @throws ParseException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public void showMenu(String userType,ReShow r)
|
||||
public void showMenu(String userType,ReShow r) throws FileNotFoundException, ClassNotFoundException, ParseException, IOException
|
||||
{
|
||||
if(userType.equals("Admin"))
|
||||
AdminSession.showAdminMenu(this,r);
|
||||
else
|
||||
ClientSession.showClientMenu(this,r);
|
||||
}
|
||||
|
||||
public void nuovoProdotto()
|
||||
/**
|
||||
* Questo metodo permette l'inserimento di un nuovo deal all'interno del catalogo
|
||||
* @throws ParseException
|
||||
* @throws IOException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public void nuovoProdotto() throws ParseException, FileNotFoundException, ClassNotFoundException, IOException
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("--------- Aggiunta nuovo Prodotto ----------");
|
||||
System.out.println("1 --> Vacanza");
|
||||
System.out.println("2 --> Cena");
|
||||
System.out.println("3 --> Bene di consumo ");
|
||||
|
||||
String sceltaMenu;
|
||||
System.out.print("Prodotto: ");
|
||||
Scanner inputData = new Scanner(System.in);
|
||||
sceltaMenu = inputData.nextLine();
|
||||
//Controllo input. La scelta deve essere obbligatoriamente compresa tra 1 e 4
|
||||
for ( ; !(sceltaMenu.equals("1"))&&!(sceltaMenu.equals("2"))&&!(sceltaMenu.equals("3")) ; ){
|
||||
System.out.println("Scelta Errata. Riprovare");
|
||||
System.out.print("Prodotto: ");
|
||||
sceltaMenu = inputData.nextLine();
|
||||
}
|
||||
|
||||
switch(sceltaMenu)
|
||||
{
|
||||
case "1":
|
||||
System.out.println("Localita: ");
|
||||
String localita = inputData.nextLine();
|
||||
|
||||
System.out.println("Data Partenza (GG/MM/AAAA): ");
|
||||
DateFormat format = new SimpleDateFormat( "dd/MM/yyyy" );
|
||||
Date date = format.parse(inputData.nextLine());
|
||||
GregorianCalendar dataPartenza = new GregorianCalendar();
|
||||
dataPartenza.setTime(date);
|
||||
|
||||
System.out.println("Data Scadenza offerta (GG/MM/AAAA): ");
|
||||
date = format.parse(inputData.nextLine());
|
||||
GregorianCalendar dataScadVacanza = new GregorianCalendar();
|
||||
dataScadVacanza.setTime(date);
|
||||
|
||||
System.out.println("Prezzo singola persona: ");
|
||||
String prezzo = inputData.nextLine();
|
||||
double prezzoPSing = Double.parseDouble(prezzo);
|
||||
|
||||
int idViaggio=Global.get_next_id();
|
||||
|
||||
catalogoOfferte.add(new Vacanze(idViaggio, localita, dataPartenza, dataScadVacanza, prezzoPSing));
|
||||
store_data();
|
||||
break;
|
||||
case "2":
|
||||
System.out.println("Ristorante: ");
|
||||
String ristorante = inputData.nextLine();
|
||||
|
||||
System.out.println("Localita: ");
|
||||
String localitaCena = inputData.nextLine();
|
||||
|
||||
System.out.println("Descrizione: ");
|
||||
String descrizioneCena = inputData.nextLine();
|
||||
|
||||
System.out.println("Costo a Persona: ");
|
||||
String prezzoCena = inputData.nextLine();
|
||||
double prezzoPSingCena = Double.parseDouble(prezzoCena);
|
||||
|
||||
System.out.println("Data Scadenza offerta (GG/MM/AAAA): ");
|
||||
DateFormat format2 = new SimpleDateFormat( "dd/MM/yyyy" );
|
||||
date = format2.parse(inputData.nextLine());
|
||||
GregorianCalendar dataScadCena = new GregorianCalendar();
|
||||
dataScadCena.setTime(date);
|
||||
|
||||
System.out.println("Cene da Vendere: ");
|
||||
String nCene = inputData.nextLine();
|
||||
int ceneDaVendere = Integer.parseInt(nCene);
|
||||
|
||||
int idCena=Global.get_next_id();
|
||||
|
||||
catalogoOfferte.add(new CeneInRistoranti(idCena, ristorante, localitaCena, descrizioneCena, prezzoPSingCena, dataScadCena, ceneDaVendere));
|
||||
store_data();
|
||||
break;
|
||||
case "3":
|
||||
System.out.println("Descrizione: ");
|
||||
String descrizioneBene = inputData.nextLine();
|
||||
|
||||
System.out.println("Prezzo Bene: ");
|
||||
String prezzoBene = inputData.nextLine();
|
||||
int prezzo_bene = Integer.parseInt(prezzoBene);
|
||||
|
||||
System.out.println("Quantita in magazzino: ");
|
||||
String qntMag = inputData.nextLine();
|
||||
int qnt_mag = Integer.parseInt(prezzoBene);
|
||||
|
||||
int idBene=Global.get_next_id();
|
||||
|
||||
catalogoOfferte.add(new BeniDiConsumo(idBene, descrizioneBene, prezzo_bene, qnt_mag));
|
||||
store_data();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void cancellaProdotto()
|
||||
{
|
||||
System.out.println("--------- Elimina Prodotto ----------");
|
||||
System.out.println("1 --> Vacanza");
|
||||
System.out.println("2 --> Cena");
|
||||
System.out.println("3 --> Bene di consumo ");
|
||||
|
||||
String sceltaMenu;
|
||||
System.out.print("Prodotto: ");
|
||||
Scanner inputData = new Scanner(System.in);
|
||||
sceltaMenu = inputData.nextLine();
|
||||
//Controllo input. La scelta deve essere obbligatoriamente compresa tra 1 e 4
|
||||
for ( ; !(sceltaMenu.equals("1"))&&!(sceltaMenu.equals("2"))&&!(sceltaMenu.equals("3")) ; ){
|
||||
System.out.println("Scelta Errata. Riprovare");
|
||||
System.out.print("Prodotto: ");
|
||||
sceltaMenu = inputData.nextLine();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void offerteAttive()
|
||||
{
|
||||
|
||||
for(Utilizzabile deal: catalogoOfferte)
|
||||
{
|
||||
if(deal instanceof Vacanze)
|
||||
{
|
||||
Vacanze dealVacanza = (Vacanze)deal;
|
||||
GregorianCalendar partenza = dealVacanza.getDataPartenzaViaggio();
|
||||
int giornoP = partenza.get(Calendar.DAY_OF_MONTH);
|
||||
int meseP = partenza.get(Calendar.MONTH);
|
||||
int annoP = partenza.get(Calendar.YEAR);
|
||||
GregorianCalendar scadenza = dealVacanza.getScadenzaOfferta();
|
||||
int giornoS = scadenza.get(Calendar.DAY_OF_MONTH);
|
||||
int meseS = scadenza.get(Calendar.MONTH);
|
||||
int annoS = scadenza.get(Calendar.YEAR);
|
||||
|
||||
System.out.println("#Vacanza-"+dealVacanza.getIdViaggio()+"# Scadenza: "+giornoS+"/"+meseS+"/"+annoS+"| Localita: "+dealVacanza.getLocalitaViaggio()+"| Partenza: "+giornoP+"/"+meseP+"/"+annoP+"| Prezzo Pers. Singola: "+dealVacanza.getPrezzoPSingola());
|
||||
}
|
||||
if(deal instanceof BeniDiConsumo)
|
||||
{
|
||||
BeniDiConsumo dealBene = (BeniDiConsumo)deal;
|
||||
System.out.println("#Articolo-"+dealBene.getIdBene()+"# Descrizione: "+dealBene.getDescrizioneBene()+"\n Prezzo: "+dealBene.getPrezzoBene()+"Quantita in magazzino: "+dealBene.getBeniInStock());
|
||||
}
|
||||
if(deal instanceof CeneInRistoranti)
|
||||
{
|
||||
CeneInRistoranti dealCena = (CeneInRistoranti)deal;
|
||||
GregorianCalendar scadenzaCena = dealCena.getDataScadenzaOffertaCena();
|
||||
int giornoSC = scadenzaCena.get(Calendar.DAY_OF_MONTH);
|
||||
int meseSC = scadenzaCena.get(Calendar.MONTH);
|
||||
int annoSC = scadenzaCena.get(Calendar.YEAR);
|
||||
System.out.println("#Cena-"+dealCena.getIdCena()+"# Scadenza:"+giornoSC+"/"+meseSC+"/"+annoSC+"| Ristorante: "+dealCena.getNomeRistorante()+"| Indirizzo: "+dealCena.getLuogo()+"| Descrizione: "+dealCena.getDescrizione_cena()+"| Costo: "+dealCena.getCostoPerPersona());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void offerteScadute()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void aggiungiCredito()
|
||||
{}
|
||||
|
||||
|
||||
public ArrayList<Utilizzabile> getCatalogo() {
|
||||
return catalogoOfferte;
|
||||
|
||||
Reference in New Issue
Block a user