Opzione 2
This commit is contained in:
@@ -43,6 +43,10 @@ public class ContoCorrente {
|
|||||||
return numeroContoCorrente;
|
return numeroContoCorrente;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void versa(double quantita){
|
||||||
|
this.saldo += quantita;
|
||||||
|
}
|
||||||
|
|
||||||
public void preleva(double quantita) throws IllegalArgumentException{
|
public void preleva(double quantita) throws IllegalArgumentException{
|
||||||
if (quantita >= this.saldo) {
|
if (quantita >= this.saldo) {
|
||||||
throw new IllegalArgumentException("La quantità desiderata eccede il saldo corrente.");
|
throw new IllegalArgumentException("La quantità desiderata eccede il saldo corrente.");
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class MyBank {
|
|||||||
do {
|
do {
|
||||||
System.out.println("Scegliere un'opzione:");
|
System.out.println("Scegliere un'opzione:");
|
||||||
System.out.println("1. Aprire conto corrente");
|
System.out.println("1. Aprire conto corrente");
|
||||||
System.out.println("2. ");
|
System.out.println("2. Versamento");
|
||||||
System.out.println("3. Prelievo");
|
System.out.println("3. Prelievo");
|
||||||
System.out.println("4. ");
|
System.out.println("4. ");
|
||||||
System.out.println("0. Esci");
|
System.out.println("0. Esci");
|
||||||
@@ -66,7 +66,7 @@ public class MyBank {
|
|||||||
if (conti.isEmpty()) {
|
if (conti.isEmpty()) {
|
||||||
System.out.println(ERRORE_CONTI_VUOTO);
|
System.out.println(ERRORE_CONTI_VUOTO);
|
||||||
} else {
|
} else {
|
||||||
|
versa(conti);
|
||||||
}
|
}
|
||||||
pausa();
|
pausa();
|
||||||
break;
|
break;
|
||||||
@@ -246,6 +246,10 @@ public class MyBank {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void versa(ArrayList<ContoCorrente> conti) {
|
||||||
|
selezionaConto(conti).versa(quantita("da versare"));
|
||||||
|
}
|
||||||
|
|
||||||
static void preleva(ArrayList<ContoCorrente> conti) {
|
static void preleva(ArrayList<ContoCorrente> conti) {
|
||||||
boolean error;
|
boolean error;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user