diff --git a/src/mybank/ContoCorrente.java b/src/mybank/ContoCorrente.java index f52f144..546a8d5 100644 --- a/src/mybank/ContoCorrente.java +++ b/src/mybank/ContoCorrente.java @@ -4,10 +4,24 @@ */ package mybank; +import java.util.Date; + /** * * @author Verde */ public class ContoCorrente { + String nome; + String cognome; + String codiceFiscale; + Date dataDiNascita; + double saldoIniziale; + public ContoCorrente(String nome, String cognome, String codiceFiscale, Date dataDiNascita, double saldoIniziale) { + this.nome = nome; + this.cognome = cognome; + this.codiceFiscale = codiceFiscale; + this.dataDiNascita = dataDiNascita; + this.saldoIniziale = saldoIniziale; + } } \ No newline at end of file diff --git a/src/mybank/MyBank.java b/src/mybank/MyBank.java index 9b6ce53..3c055ad 100644 --- a/src/mybank/MyBank.java +++ b/src/mybank/MyBank.java @@ -4,6 +4,10 @@ */ package mybank; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; import java.util.InputMismatchException; import java.util.Scanner; @@ -18,13 +22,15 @@ public class MyBank { */ static Scanner sc = new Scanner(System.in); + static final String ERRORE_GENERICO = "Errore: opzione non valida."; public static void main(String[] args) { int scelta = -1; + ArrayList conti = new ArrayList<>(); do { System.out.println("Scegliere un'opzione:"); - System.out.println("1. "); + System.out.println("1. Aggiungi conto corrente"); System.out.println("2. "); System.out.println("3. "); System.out.println("0. Esci"); @@ -38,15 +44,24 @@ public class MyBank { case 0: break; case 1: - + aggiungiConto(conti); + System.out.println("Conto corrente aggiunto con successo."); pausa(); break; case 2: - + if(conti.isEmpty()){ + System.out.println("Errore: è necessario aggiungere almeno un conto corrente prima di proseguire."); + }else{ + + } pausa(); break; case 3: - + if(conti.isEmpty()){ + System.out.println("Errore: è necessario aggiungere almeno un conto corrente prima di proseguire."); + }else{ + + } pausa(); break; default: @@ -54,8 +69,7 @@ public class MyBank { pausa(); break; } - } - catch (InputMismatchException _) { + } catch (InputMismatchException _) { System.out.println("Errore: scelta non valida."); pausa(); } @@ -66,4 +80,73 @@ public class MyBank { System.out.println("Premere un tasto per continuare. . ."); sc.nextLine(); } + + static void aggiungiConto(ArrayList conti) { + String nome; + String cognome; + String codiceFiscale; + Date dataDiNascita; + double saldoIniziale; + + System.out.print("Inserire il proprio nome: "); + nome = sc.nextLine().trim(); + + System.out.print("Inserire il proprio cognome: "); + cognome = sc.nextLine().trim(); + + // TODO: codiceFiscale da prendere da vecchio programma + codiceFiscale = "XDKEKW"; + + dataDiNascita = dataDiNascita(); + + saldoIniziale = saldoIniziale(); + + conti.add(new ContoCorrente(nome, cognome, codiceFiscale, dataDiNascita, saldoIniziale)); + } + + static Date dataDiNascita() { + Date dataDiNascita = null; + boolean error; + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + sdf.setLenient(false); + + do { + error = false; + System.out.print("Inserire la propria data di nascita: "); + try { + dataDiNascita = sdf.parse(sc.nextLine()); + } catch (ParseException _) { + System.out.println("Errore: la data inserita non è valida."); + pausa(); + error = true; + } + } while (error); + return dataDiNascita; + } + + static double saldoIniziale() { + double saldoIniziale = 0; + boolean error; + + do { + error = false; + System.out.print("Inserire il saldo iniziale: "); + try { + saldoIniziale = sc.nextDouble(); + sc.nextLine(); + + if (saldoIniziale <= 0) { + System.out.println("Errore: il saldo iniziale non può essere minore o uguale a zero."); + pausa(); + error = true; + } + } catch (InputMismatchException _) { + System.out.println(ERRORE_GENERICO); + pausa(); + error = true; + } + } while (error); + + return saldoIniziale; + } } diff --git a/src/mybank/build.xml b/src/mybank/build.xml new file mode 100644 index 0000000..9d9fbae --- /dev/null +++ b/src/mybank/build.xml @@ -0,0 +1,5 @@ + + + Builds, tests, and runs the project DIRDIR. + + diff --git a/src/mybank/nbproject/build-impl.xml b/src/mybank/nbproject/build-impl.xml new file mode 100644 index 0000000..c285611 --- /dev/null +++ b/src/mybank/nbproject/build-impl.xml @@ -0,0 +1,1771 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mybank/nbproject/private/private.properties b/src/mybank/nbproject/private/private.properties new file mode 100644 index 0000000..d48d617 --- /dev/null +++ b/src/mybank/nbproject/private/private.properties @@ -0,0 +1,3 @@ +compile.on.save=true +user.properties.file=/home/Verde/.netbeans/28/build.properties + diff --git a/src/mybank/nbproject/project.properties b/src/mybank/nbproject/project.properties new file mode 100644 index 0000000..60bc7e9 --- /dev/null +++ b/src/mybank/nbproject/project.properties @@ -0,0 +1,95 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/mybank.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/mybank +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=25 +javac.target=25 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=mybank +main.class=mybank.mybank +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/src/mybank/nbproject/project.xml b/src/mybank/nbproject/project.xml new file mode 100644 index 0000000..01d13e8 --- /dev/null +++ b/src/mybank/nbproject/project.xml @@ -0,0 +1,16 @@ + + + org.netbeans.modules.java.j2seproject + + + mybank + + + + + + + + + +