Errori grafici

This commit is contained in:
La Programmatrice Verde
2026-03-03 11:48:04 +01:00
parent d6f140dae7
commit 79da3567a4
9 changed files with 16 additions and 44 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -7,6 +7,7 @@ package gui;
import java.awt.Color;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.regex.Pattern;
import logic.MyBank;
@@ -33,6 +34,12 @@ public class GUIMyBank extends javax.swing.JFrame {
*/
public GUIMyBank() {
initComponents();
try {
ArrayList<ContoCorrente> conti = (ArrayList<ContoCorrente>) MyBank.importaConti();
MyBank.setConti(conti);
} catch (IOException e) {
JOptionPane.showMessageDialog(null, e.getMessage());
}
lblNumeroContoCorrente.setVisible(false);
txtNumeroContoCorrente.setVisible(false);
txtNumeroContoCorrente.setEditable(false);

View File

@@ -14,9 +14,8 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -36,49 +35,17 @@ public class MyBank {
static final String ERRORE_GENERICO = "Errore: opzione non valida.";
static final String ERRORE_CONTI_VUOTO = "Errore: è necessario aggiungere almeno un conto corrente prima di proseguire.";
public static final String PATH_CONTI = "./src/logic/conti/";
private static ArrayList<ContoCorrente> conti = importaConti();
private static ArrayList<ContoCorrente> conti;
public static void setConti(ArrayList<ContoCorrente> conti) {
MyBank.conti = conti;
}
public static ArrayList<ContoCorrente> getConti() {
return conti;
}
public static void main(String[] args) {
int scelta = -1;
do {
System.out.println("Scegliere un'opzione:");
System.out.println("1. Aprire conto corrente");
System.out.println("2. Versamento");
System.out.println("3. Prelievo");
System.out.println("4. Mostra movimenti");
System.out.println("0. Esci");
System.out.print("Opzione: ");
try {
scelta = sc.nextInt();
sc.nextLine();
switch (scelta) {
case 0:
break;
default:
System.out.println(ERRORE_GENERICO);
pausa();
break;
}
} catch (InputMismatchException _) {
System.out.println(ERRORE_GENERICO);
pausa();
}
} while (scelta != 0);
}
public static void pausa() {
System.out.println("Premere un tasto per continuare. . .");
sc.nextLine();
}
static ArrayList<ContoCorrente> importaConti() {
public static List<ContoCorrente> importaConti() throws IOException{
ArrayList<ContoCorrente> conti = new ArrayList<>();
File percorsoConti = new File(PATH_CONTI);
ObjectMapper mapper = new ObjectMapper();
@@ -104,10 +71,8 @@ public class MyBank {
numeriContiCorrenti.add(conti.getLast().getNumeroContoCorrente());
ContoCorrente.setNumeriContiCorrenti(numeriContiCorrenti);
} catch (Exception e) {
System.out.println("Errore nella lettura del file di conto corrente.");
System.out.println(e.getMessage());
System.out.println(e.getStackTrace());
} catch (IOException e) {
throw new IOException("Errore nella lettura del file di conto corrente:\n" + e.getMessage());
}
}
}