Opzione 1
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<ContoCorrente> 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<ContoCorrente> 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;
|
||||
}
|
||||
}
|
||||
|
||||
5
src/mybank/build.xml
Normal file
5
src/mybank/build.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="DIRDIR" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project DIRDIR.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
</project>
|
||||
1771
src/mybank/nbproject/build-impl.xml
Normal file
1771
src/mybank/nbproject/build-impl.xml
Normal file
File diff suppressed because it is too large
Load Diff
3
src/mybank/nbproject/private/private.properties
Normal file
3
src/mybank/nbproject/private/private.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
compile.on.save=true
|
||||
user.properties.file=/home/Verde/.netbeans/28/build.properties
|
||||
|
||||
95
src/mybank/nbproject/project.properties
Normal file
95
src/mybank/nbproject/project.properties
Normal file
@@ -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
|
||||
16
src/mybank/nbproject/project.xml
Normal file
16
src/mybank/nbproject/project.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.java.j2seproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>mybank</name>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user