Menu in RAM + correzione stringhe
This commit is contained in:
@@ -36,6 +36,7 @@ public class FatturaScontrini {
|
||||
static final String ERRORE_DEFAULT = "Errore: opzione non valida.";
|
||||
static final String ERRORE_FILE = "Errore nella lettura del file: ";
|
||||
static final String ERRORE_MENU_VUOTO = "Errore: il menu è vuoto.";
|
||||
static String[][] menu = tabellaNomePrezzo();
|
||||
static int codiceScontrino = getCodice(0);
|
||||
|
||||
public static void main(String[] args) {
|
||||
@@ -182,7 +183,7 @@ public class FatturaScontrini {
|
||||
System.out.print("Scelta: ");
|
||||
|
||||
try {
|
||||
voceSelezionata = sc.nextInt();
|
||||
voceSelezionata = sc.nextInt() - 1;
|
||||
sc.nextLine();
|
||||
|
||||
if (voceSelezionata < 0 || voceSelezionata >= getFileSize(PATH_MENU)) {
|
||||
@@ -201,17 +202,8 @@ public class FatturaScontrini {
|
||||
}
|
||||
|
||||
static void stampaMenu() {
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(PATH_MENU))) {
|
||||
StringTokenizer st;
|
||||
String riga = br.readLine();
|
||||
|
||||
for (int i = 0; i < getFileSize(PATH_MENU); i++) {
|
||||
st = new StringTokenizer(riga, ":");
|
||||
System.out.println(i + ". " + st.nextToken() + ": " + st.nextToken().trim());
|
||||
riga = br.readLine();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println(ERRORE_FILE + e.getMessage());
|
||||
for (int i = 0; i < menu[0].length; i++) {
|
||||
System.out.println((i+1) + ". " + menu[0][i] + ": " + menu[1][i].trim());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +285,6 @@ public class FatturaScontrini {
|
||||
|
||||
static String ordinazioneToString(ArrayList<int[]> ordinazione) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String[][] menu = tabellaNomePrezzo();
|
||||
double totale = 0;
|
||||
|
||||
// Larghezze colonne
|
||||
@@ -369,7 +360,6 @@ public class FatturaScontrini {
|
||||
|
||||
static ArrayList<int[]> cancellaOrdine(ArrayList<int[]> ordinazione) {
|
||||
int scelta = -1;
|
||||
String[][] menu = tabellaNomePrezzo();
|
||||
boolean error;
|
||||
|
||||
do {
|
||||
@@ -489,6 +479,7 @@ public class FatturaScontrini {
|
||||
break;
|
||||
case 2:
|
||||
aggiungiVoceMenu();
|
||||
menu = tabellaNomePrezzo();
|
||||
System.out.println("Piatto aggiunto con successo.");
|
||||
pausa();
|
||||
break;
|
||||
@@ -598,7 +589,7 @@ public class FatturaScontrini {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
System.out.print("Inserire il nome della nuova voce: ");
|
||||
nome = sc.nextLine().trim();
|
||||
System.out.print("Inserire il prezzo della nuova voce: ");
|
||||
System.out.println("Inserire il prezzo della nuova voce");
|
||||
prezzo = Double.toString(prezzo());
|
||||
|
||||
if (prezzo.contains(",")) {
|
||||
@@ -623,7 +614,7 @@ public class FatturaScontrini {
|
||||
do {
|
||||
error = false;
|
||||
|
||||
System.out.print("Inserire il prezzo da acquistare: ");
|
||||
System.out.print("Prezzo: ");
|
||||
|
||||
try {
|
||||
prezzo = sc.nextDouble();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
numeroScontrino:257
|
||||
numeroFattura:7
|
||||
numeroScontrino:258
|
||||
numeroFattura:8
|
||||
username: password
|
||||
password: username
|
||||
|
||||
Reference in New Issue
Block a user