From c7a3d14a32bd965283d1576a04f36935b4170878 Mon Sep 17 00:00:00 2001 From: La Programmatrice Verde Date: Tue, 4 Nov 2025 11:50:28 +0100 Subject: [PATCH] Struttura base --- src/appComune/Anagrafica.java | 53 +++++++++++++++++++++++- src/appComune/GestisciCodiceFiscale.java | 33 ++++++++++++++- src/appComune/GestisciStringhe.java | 13 ------ src/appComune/MainComune.java | 48 ++++++++++++++++++++- src/utility/GestisciStringhe.java | 43 +++++++++++++++++++ 5 files changed, 174 insertions(+), 16 deletions(-) delete mode 100644 src/appComune/GestisciStringhe.java create mode 100644 src/utility/GestisciStringhe.java diff --git a/src/appComune/Anagrafica.java b/src/appComune/Anagrafica.java index 2a4f987..8fead5c 100644 --- a/src/appComune/Anagrafica.java +++ b/src/appComune/Anagrafica.java @@ -2,7 +2,11 @@ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template */ -package appcomune; +package appComune; + +import java.text.SimpleDateFormat; + +import javax.swing.text.SimpleAttributeSet; /** * @@ -10,4 +14,51 @@ package appcomune; */ public class Anagrafica { + String nome; + String cognome; + Date dataNascita; + String luogoNascita; + String sesso; + String CF; + + public Anagrafica(String nome, String cognome, Date dataNascita, String luogo, String sesso) { + this.nome = nome; + this.cognome = cognome; + this.dataNascita = dataNascita; + this.luogoNascita = luogo; + this.sesso = sesso; + this.CF = GestisciCodiceFiscale.CalcolaCodiceFiscale(nome, cognome, dataNascita, luogo, sesso); + } + + public String toString() { + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + String ritorno = "Nome: " + this.nome + "\nCognome: " + this.cognome + "\nData di nascita: " + + sdf.parse(this.dataNascita) + "\nLuogo di nascita: " + this.luogoNascita + "\nSesso: " + this.sesso + + "\nCodice fiscale: " + this.CF; + return ritorno; + } + + public String getNome() { + return nome; + } + + public String getCognome() { + return cognome; + } + + public Date getDataNascita() { + return dataNascita; + } + + public String getLuogoNascita() { + return luogoNascita; + } + + public String getSesso() { + return sesso; + } + + public String getCF() { + return CF; + } } \ No newline at end of file diff --git a/src/appComune/GestisciCodiceFiscale.java b/src/appComune/GestisciCodiceFiscale.java index f0cb1aa..32ece8b 100644 --- a/src/appComune/GestisciCodiceFiscale.java +++ b/src/appComune/GestisciCodiceFiscale.java @@ -2,12 +2,43 @@ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template */ -package appcomune; +package appComune; /** * * @author Verde */ public class GestisciCodiceFiscale { + public static String CalcolaCodiceFiscale(String nome, String cognome, Date dataNascita, String luogo, + String sesso) { + } + + static String CalcolaPrimaTerna(String cognome){ + + } + + static String CalcolaSecondaTerna(String nome) { + + } + + static String CalcolaSettimoOttavo(Date dataNascita) { + + } + + static String CalcolaNono(Date dataNascita) { + + } + + static String CalcolaDecimoUndicesimo(Date dataNascita, String sesso) { + + } + + static String CalcolaFrom12To15(String luogoNascita) { + + } + + static String CalcolaSedicesimo() { + + } } \ No newline at end of file diff --git a/src/appComune/GestisciStringhe.java b/src/appComune/GestisciStringhe.java deleted file mode 100644 index 7b3762d..0000000 --- a/src/appComune/GestisciStringhe.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template - */ -package appcomune; - -/** - * - * @author Verde - */ -public class GestisciStringhe { - -} \ No newline at end of file diff --git a/src/appComune/MainComune.java b/src/appComune/MainComune.java index c95b339..67420b6 100644 --- a/src/appComune/MainComune.java +++ b/src/appComune/MainComune.java @@ -2,12 +2,58 @@ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template */ -package appcomune; +package appComune; + +import java.util.InputMismatchException; +import java.util.Scanner; /** * * @author Verde */ public class MainComune { + static Scanner sc = new Scanner(System.in); + + public static void main(String[] args) { + int scelta = -1; + + do { + System.out.println("Scegliere un'opzione:"); + System.out.println("1. Inserisci dati"); + System.out.println("2. Stampa dati"); + System.out.println("0. Esci"); + System.out.print("Opzione: "); + + try { + scelta = sc.nextInt(); + sc.nextLine(); + + switch (scelta) { + case 0: + break; + case 1: + + pausa(); + break; + case 2: + + pausa(); + break; + default: + System.out.println("Opzione non valida."); + pausa(); + break; + } + } catch (InputMismatchException _) { + System.out.println("Errore: scelta non valida."); + pausa(); + } + } while (scelta != 0); + } + + public static void pausa() { + System.out.println("Premere un tasto per continuare. . ."); + sc.nextLine(); + } } \ No newline at end of file diff --git a/src/utility/GestisciStringhe.java b/src/utility/GestisciStringhe.java new file mode 100644 index 0000000..1146f7e --- /dev/null +++ b/src/utility/GestisciStringhe.java @@ -0,0 +1,43 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package utility; + +/** + * + * @author Verde + */ +public class GestisciStringhe { + public static int ContaOccorrenze(String testo, String testoDaCercare) { + + } + + public static int ContaOccorrenze(String testo, char tipo) { + + } + + public static int trovaPosizioneOccorrenza(String testo, String testoDaCercare) { + + } + + public static int trovaPosizioneOccorrenza(String testo, String testoDaCercare, int nrOccorrenza) { + + } + + public static char estraiCarattere(String testo, char tipo, int nrOccorrenza) { + + } + + public static boolean isVocale(char carattere) { + + } + + public static boolean isConsonante(char carattere) { + + } + + public static String rimuoviCarattere(String testo, String carattere) { + + } +} \ No newline at end of file