/*
Copyright (C) 2013 Alessandro Bugatti (alessandro.bugatti@istruzione.it)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* Classe semplice per gestire la creazione di un preventivo per auto
* \author Alessandro Bugatti
*
* version 0.1
* date Creazione 07/03/2009
* date Ultima modifica 23/10/2013
*
*/
package configuratoreauto;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author Alessandro Bugatti
*/
public class ConfiguratoreAuto {
private static PreventivoAuto p;
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
p = new PreventivoAuto();
int scelta;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PreventivoAuto.recuperaDati();
do
{
menu();
scelta = Integer.parseInt(br.readLine());
switch (scelta)
{
case 1:
scegliModello();
break;
case 2:
scegliMotorizzazione();
break;
case 3:
stampaPreventivo();
break;
}
}
while (scelta != 0);
}
private static void menu()
{
System.out.println( "Calcolo del preventivo per auto");
System.out.println( "1) Scegli il modello" );
System.out.println( "2) Scegli la motorizzazione" );
System.out.println( "3) Stampa preventivo" );
System.out.println( "0) Esci");
}
private static void scegliModello() throws IOException
{
int scelta;
String[] modelli;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
modelli = PreventivoAuto.getModelli();
for (int i = 0; i< modelli.length; i++)
System.out.println( (i+ 1) + ") " + modelli[i]);
scelta = Integer.parseInt(br.readLine());
p.setModello(scelta-1);
}
private static void scegliMotorizzazione() throws IOException
{
int scelta;
String[] motorizzazioni;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
motorizzazioni = PreventivoAuto.getMotorizzazioni();
for (int i = 0; i< motorizzazioni.length; i++)
System.out.println( i+ 1 + ") " + motorizzazioni[i]);
scelta = Integer.parseInt(br.readLine());
p.setMotorizzazione(scelta-1);
}
private static void stampaPreventivo()
{
System.out.println( p.getRiepilogo());
System.out.println( "Il preventivo e' di " + p.getPreventivo() + " euro");
}
}