PagamentiOnline + correzione classi
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
package pagamentionline;
|
package pagamentionline;
|
||||||
|
|
||||||
import java.util.InputMismatchException;
|
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,50 +19,15 @@ public class PagamentiOnline {
|
|||||||
static Scanner sc = new Scanner(System.in);
|
static Scanner sc = new Scanner(System.in);
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int scelta = -1;
|
Pagamento contanti = new Pagamento(25.25);
|
||||||
|
PagamentoCartaCredito intesa = new PagamentoCartaCredito(250.99, "1234-5678-9101-3456");
|
||||||
|
PagamentoPayPal pagoPalla = new PagamentoPayPal(2001.27, "'@'@[::1]");
|
||||||
|
|
||||||
do {
|
System.out.println(contanti.paga());
|
||||||
System.out.println("Scegliere un'opzione:");
|
System.out.println(contanti.paga("Pane e acqua"));
|
||||||
System.out.println("1. ");
|
System.out.println(intesa.paga());
|
||||||
System.out.println("2. ");
|
System.out.println(intesa.paga("Kompiutah"));
|
||||||
System.out.println("3. ");
|
System.out.println(pagoPalla.paga());
|
||||||
System.out.println("0. Esci");
|
System.out.println(pagoPalla.paga("Megah Kompiutah"));
|
||||||
System.out.print("Opzione: ");
|
|
||||||
|
|
||||||
try {
|
|
||||||
scelta = sc.nextInt();
|
|
||||||
sc.nextLine();
|
|
||||||
|
|
||||||
switch (scelta) {
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
|
|
||||||
pausa();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
|
|
||||||
pausa();
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public class PagamentoCartaCredito extends Pagamento{
|
|||||||
this.numeroCarta = numeroCarta;
|
this.numeroCarta = numeroCarta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String paga() {
|
public String paga() {
|
||||||
return "Pagamento di " + this.importo + " euro effettuato con carta di credito numero " + this.numeroCarta;
|
return "Pagamento di " + this.importo + " euro effettuato con carta di credito numero " + this.numeroCarta;
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ package pagamentionline;
|
|||||||
*
|
*
|
||||||
* @author Verde
|
* @author Verde
|
||||||
*/
|
*/
|
||||||
public class PagamentoPayPal {
|
public class PagamentoPayPal extends Pagamento {
|
||||||
String emailUtente;
|
String emailUtente;
|
||||||
|
|
||||||
public PagamentoPayPal(double importo, String emailUtente) {
|
public PagamentoPayPal(double importo, String emailUtente) {
|
||||||
@@ -16,6 +16,7 @@ public class PagamentoPayPal {
|
|||||||
this.emailUtente = emailUtente;
|
this.emailUtente = emailUtente;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String paga() {
|
public String paga() {
|
||||||
return "Pagamento di " + this.importo + " euro effettuato tramite PayPal dall'account " + this.emailUtente;
|
return "Pagamento di " + this.importo + " euro effettuato tramite PayPal dall'account " + this.emailUtente;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user