CreaBiblioteca
This commit is contained in:
parent
16b04931c6
commit
6d125ffc5a
61
Program.cs
61
Program.cs
@ -28,7 +28,6 @@ class Program {
|
|||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
Console.Clear();
|
|
||||||
dispensers[i] = new Dispenser();
|
dispensers[i] = new Dispenser();
|
||||||
i++;
|
i++;
|
||||||
Console.WriteLine("Dispenser standard creato.");
|
Console.WriteLine("Dispenser standard creato.");
|
||||||
@ -36,7 +35,6 @@ class Program {
|
|||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
Console.Clear();
|
|
||||||
if (i > dispensers.Length - 1) {
|
if (i > dispensers.Length - 1) {
|
||||||
Console.WriteLine($"Errore: non si possono creare più di {dispensers.Length} dispensers.");
|
Console.WriteLine($"Errore: non si possono creare più di {dispensers.Length} dispensers.");
|
||||||
}
|
}
|
||||||
@ -74,7 +72,6 @@ class Program {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
Console.Clear();
|
|
||||||
oggettoEsistente = true;
|
oggettoEsistente = true;
|
||||||
for (int j = 0; j < dispensers.Length && oggettoEsistente; j++) {
|
for (int j = 0; j < dispensers.Length && oggettoEsistente; j++) {
|
||||||
if (dispensers[j] == null) {
|
if (dispensers[j] == null) {
|
||||||
@ -95,7 +92,6 @@ class Program {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
Console.Clear();
|
|
||||||
quantitàRimasta = SelezionaDispenser(dispensers).Erogazione();
|
quantitàRimasta = SelezionaDispenser(dispensers).Erogazione();
|
||||||
if (quantitàRimasta == 0) {
|
if (quantitàRimasta == 0) {
|
||||||
Console.WriteLine("Il dispenser è vuoto.");
|
Console.WriteLine("Il dispenser è vuoto.");
|
||||||
@ -120,6 +116,61 @@ class Program {
|
|||||||
static void Pausa() {
|
static void Pausa() {
|
||||||
Console.WriteLine("Premere un tasto per continuare. . .");
|
Console.WriteLine("Premere un tasto per continuare. . .");
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
Console.Clear();
|
}
|
||||||
|
|
||||||
|
static void CreaBiblioteca(Libro[] p_biblioteca) {
|
||||||
|
string nome;
|
||||||
|
double prezzo;
|
||||||
|
int numeroScaffale;
|
||||||
|
int numeroPagine;
|
||||||
|
string casaEditrice;
|
||||||
|
|
||||||
|
for (int i = 0; i < p_biblioteca.Length; i++) {
|
||||||
|
Console.Write("Inserire il titolo del libro: ");
|
||||||
|
nome = Console.ReadLine();
|
||||||
|
|
||||||
|
do {
|
||||||
|
Console.Write("Inserire il prezzo del libro:");
|
||||||
|
prezzo = Convert.ToDouble(Console.ReadLine());
|
||||||
|
if (prezzo <= 0) {
|
||||||
|
Console.WriteLine("Errore: il prezzo non può essere minore o uguale a zero.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (prezzo <= 0);
|
||||||
|
|
||||||
|
do {
|
||||||
|
Console.Write("Inserire il numero di pagine del libro:");
|
||||||
|
numeroPagine = Convert.ToInt32(Console.ReadLine());
|
||||||
|
if (numeroPagine <= 0) {
|
||||||
|
Console.WriteLine("Errore: il numero di pagine non può essere minore o uguale a zero.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (numeroPagine <= 0);
|
||||||
|
|
||||||
|
Console.Write("Inserire la casa editrice: ");
|
||||||
|
casaEditrice = Console.ReadLine();
|
||||||
|
|
||||||
|
do {
|
||||||
|
Console.WriteLine("Scegliere il numero di scaffale:");
|
||||||
|
for (int j = 0; j < p_biblioteca.Length; j++) {
|
||||||
|
Console.WriteLine($"{j}");
|
||||||
|
}
|
||||||
|
Console.Write("Scelta: ");
|
||||||
|
numeroScaffale = Convert.ToInt32(Console.ReadLine());
|
||||||
|
if (numeroScaffale < 0 || numeroScaffale > p_biblioteca.Length) {
|
||||||
|
Console.WriteLine("Numero di scaffale non valido.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
if (p_biblioteca[numeroScaffale] != null) {
|
||||||
|
Console.WriteLine("Scaffale occupato, sceglierne un altro.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (numeroScaffale < 0 || numeroScaffale > p_biblioteca.Length || p_biblioteca[numeroScaffale] != null);
|
||||||
|
|
||||||
|
p_biblioteca[numeroScaffale] = new Libro(nome, prezzo, Convert.ToString(numeroScaffale), Convert.ToString(numeroPagine), casaEditrice);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user