StampaLibro
This commit is contained in:
parent
6d125ffc5a
commit
fcdd94b6d4
48
Program.cs
48
Program.cs
@ -4,7 +4,7 @@ class Program {
|
|||||||
static void Main(string[] args) {
|
static void Main(string[] args) {
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
const int MAX_LIBRI = 10;
|
const int MAX_LIBRI = 10;
|
||||||
int scelta, input, i = 0;
|
int scelta, input;
|
||||||
Libro[] biblioteca = new Libro[MAX_LIBRI];
|
Libro[] biblioteca = new Libro[MAX_LIBRI];
|
||||||
bool oggettoEsistente;
|
bool oggettoEsistente;
|
||||||
(double, bool) ritornoRiempimento;
|
(double, bool) ritornoRiempimento;
|
||||||
@ -28,45 +28,25 @@ class Program {
|
|||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
dispensers[i] = new Dispenser();
|
CreaBiblioteca(biblioteca);
|
||||||
i++;
|
|
||||||
Console.WriteLine("Dispenser standard creato.");
|
|
||||||
|
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (i > dispensers.Length - 1) {
|
oggettoEsistente = true;
|
||||||
Console.WriteLine($"Errore: non si possono creare più di {dispensers.Length} dispensers.");
|
for (int i = 0; i < biblioteca.Length && oggettoEsistente; i++) {
|
||||||
|
if (biblioteca[i] == null) {
|
||||||
|
oggettoEsistente = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!oggettoEsistente) {
|
||||||
|
Console.WriteLine("Errore: è necessario creare la biblioteca prima di mostrarla.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
do {
|
for (int i = 0; i < biblioteca.Length; i++) {
|
||||||
Console.Write("Inserire la capienza del dispenser: ");
|
Console.WriteLine($"Libro {i + 1}:");
|
||||||
capienza = Convert.ToDouble(Console.ReadLine());
|
biblioteca[i].StampaLibro();
|
||||||
if (capienza <= 0) {
|
Console.WriteLine();
|
||||||
Console.WriteLine("Errore: la capienza del dispenser non può essere minore o uguale a zero.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
while (capienza <= 0);
|
|
||||||
|
|
||||||
do {
|
|
||||||
Console.Write("Inserire la quantità erogata dal dispenser: ");
|
|
||||||
quantitàErogata = Convert.ToDouble(Console.ReadLine());
|
|
||||||
if (quantitàErogata <= 0) {
|
|
||||||
Console.WriteLine("Errore: la quantità erogata dal dispenser non può essere minore o uguale a zero.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (quantitàErogata <= 0);
|
|
||||||
|
|
||||||
do {
|
|
||||||
Console.Write("Inserire la quantità contenuta dal dispenser: ");
|
|
||||||
quantitàContenuta = Convert.ToDouble(Console.ReadLine());
|
|
||||||
if (quantitàContenuta <= 0) {
|
|
||||||
Console.WriteLine("Errore: la quantità contenuta dal dispenser non può essere minore o uguale a zero.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (quantitàContenuta <= 0);
|
|
||||||
dispensers[i] = new Dispenser(quantitàErogata, quantitàContenuta, capienza);
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user