Semplificazione dati
This commit is contained in:
@@ -20,7 +20,8 @@ public class Rettangoli_Quadrati {
|
|||||||
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) {
|
||||||
Rettangolo forme[] = Init();
|
Rettangolo rettangolo;
|
||||||
|
Rettangolo quadrato;
|
||||||
int scelta, nextPosizioneLibera = 0;
|
int scelta, nextPosizioneLibera = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -38,8 +39,8 @@ public class Rettangoli_Quadrati {
|
|||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
forme[nextPosizioneLibera] = CreaRettangolo(IngressoDati(1), IngressoDati(2));
|
rettangolo = CreaRettangolo(IngressoDati(1), IngressoDati(2));
|
||||||
forme[nextPosizioneLibera + 1] = CreaQuadrato(IngressoDati(3));
|
quadrato = CreaQuadrato(IngressoDati(3));
|
||||||
nextPosizioneLibera = +2;
|
nextPosizioneLibera = +2;
|
||||||
System.out.println("Forme create con successo");
|
System.out.println("Forme create con successo");
|
||||||
Pausa();
|
Pausa();
|
||||||
@@ -67,34 +68,6 @@ public class Rettangoli_Quadrati {
|
|||||||
sc.nextLine();
|
sc.nextLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Rettangolo[] Init() {
|
|
||||||
boolean error;
|
|
||||||
int dimensione = 0;
|
|
||||||
|
|
||||||
do {
|
|
||||||
error = false;
|
|
||||||
try {
|
|
||||||
System.out.println("Quante coppie di forme gestire? ");
|
|
||||||
|
|
||||||
dimensione = sc.nextInt();
|
|
||||||
sc.nextLine();
|
|
||||||
|
|
||||||
if (dimensione <= 0) {
|
|
||||||
System.out.println("Errore: inserire una dimensione "
|
|
||||||
+ (dimensione == 0 ? "diversa da" : "maggiore di") + " 0.");
|
|
||||||
Pausa();
|
|
||||||
error = true;
|
|
||||||
}
|
|
||||||
} catch (InputMismatchException e) {
|
|
||||||
System.out.println("Errore: dimensione non valida.");
|
|
||||||
Pausa();
|
|
||||||
error = true;
|
|
||||||
}
|
|
||||||
} while (error);
|
|
||||||
|
|
||||||
return new Rettangolo[dimensione];
|
|
||||||
}
|
|
||||||
|
|
||||||
static double IngressoDati(int p_selettore) {
|
static double IngressoDati(int p_selettore) {
|
||||||
double ritorno = 0;
|
double ritorno = 0;
|
||||||
boolean error;
|
boolean error;
|
||||||
|
|||||||
Reference in New Issue
Block a user