Controllo input e gestione eccezioni dell'opzione 2
This commit is contained in:
parent
ec1388ecb1
commit
a880e849e7
@ -65,9 +65,10 @@ class Cliente {
|
|||||||
for (i = 0; i < this.prenotazioni.Length && isPrenotazioneEsistente; i++) {
|
for (i = 0; i < this.prenotazioni.Length && isPrenotazioneEsistente; i++) {
|
||||||
if (this.prenotazioni[i] == null) {
|
if (this.prenotazioni[i] == null) {
|
||||||
isPrenotazioneEsistente = false;
|
isPrenotazioneEsistente = false;
|
||||||
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.prenotazioni[i] = isPrenotazioneEsistente ? throw new Exception("Errore: sono consentite solo 10 prenotazioni per cliente") : new Prenotazione(p_periodo, p_giorniPrenotati, p_numeroPersone, this.GetCodiceFiscale());
|
this.prenotazioni[i] = isPrenotazioneEsistente ? throw new Exception("Errore: sono già state inserite tutte le prenotazioni per questo cliente") : new Prenotazione(p_periodo, p_giorniPrenotati, p_numeroPersone, this.GetCodiceFiscale());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CancellaPrenotazione(string p_UUID) {
|
public void CancellaPrenotazione(string p_UUID) {
|
||||||
|
|||||||
29
Program.cs
29
Program.cs
@ -30,11 +30,11 @@ class Program {
|
|||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
Demo();
|
Demo();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
Menu();
|
Menu();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -92,7 +92,7 @@ class Program {
|
|||||||
|
|
||||||
Cliente[] clienti = new Cliente[numeroClienti];
|
Cliente[] clienti = new Cliente[numeroClienti];
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Console.WriteLine("Scegliere un'opzione:");
|
Console.WriteLine("Scegliere un'opzione:");
|
||||||
Console.WriteLine("1. Inserire i dati dei clienti");
|
Console.WriteLine("1. Inserire i dati dei clienti");
|
||||||
Console.WriteLine("2. Inserire una prenotazione");
|
Console.WriteLine("2. Inserire una prenotazione");
|
||||||
@ -156,6 +156,7 @@ class Program {
|
|||||||
case 2:
|
case 2:
|
||||||
string[] periodi = ["primavera", "estate", "autunno", "inverno"];
|
string[] periodi = ["primavera", "estate", "autunno", "inverno"];
|
||||||
int giorniPrenotati = 0, numeroPersone = 0;
|
int giorniPrenotati = 0, numeroPersone = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Console.WriteLine("Inserire la prenotazione di quale cliente? ");
|
Console.WriteLine("Inserire la prenotazione di quale cliente? ");
|
||||||
for (int i = 0; i < clienti.Length; i++) {
|
for (int i = 0; i < clienti.Length; i++) {
|
||||||
@ -178,9 +179,13 @@ class Program {
|
|||||||
Console.WriteLine("Opzione non valida");
|
Console.WriteLine("Opzione non valida");
|
||||||
Pausa();
|
Pausa();
|
||||||
}
|
}
|
||||||
|
else if (clienti[input - 1] == null) {
|
||||||
|
Console.WriteLine("I dati di questo cliente non sono ancora stati inseriti.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (eccezione || input <= 0 || input > numeroClienti);
|
while (eccezione || input <= 0 || input > numeroClienti || clienti[input - 1] == null);
|
||||||
|
|
||||||
scelta = 5;
|
scelta = 5;
|
||||||
do {
|
do {
|
||||||
@ -253,11 +258,21 @@ class Program {
|
|||||||
}
|
}
|
||||||
while (numeroPersone <= 0);
|
while (numeroPersone <= 0);
|
||||||
|
|
||||||
clienti[input - 1].InserisciPrenotazione(periodi[scelta], Convert.ToString(giorniPrenotati), Convert.ToString(numeroPersone));
|
eccezione = false;
|
||||||
|
|
||||||
Console.WriteLine("Prenotazione inserita correttamente.");
|
try {
|
||||||
|
clienti[input - 1].InserisciPrenotazione(periodi[scelta], Convert.ToString(giorniPrenotati), Convert.ToString(numeroPersone));
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
eccezione = true;
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
if (!eccezione) {
|
||||||
|
Console.WriteLine("Prenotazione inserita correttamente.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
|
||||||
Pausa();
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
for (int i = 0; i < numeroClienti; i++) {
|
for (int i = 0; i < numeroClienti; i++) {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("agenzia_viaggi")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("agenzia_viaggi")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f9184fea2c9646a9d311a20814a0ffb94d3afd4a")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ec1388ecb1b5b5cfc1973c4e5e8873d52feea5eb")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("agenzia_viaggi")]
|
[assembly: System.Reflection.AssemblyProductAttribute("agenzia_viaggi")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("agenzia_viaggi")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("agenzia_viaggi")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
1bc455adbb990f51be8b7d12aa7c0f4dcc419f5750faa87eb217db2284f5c44c
|
b0ce948d3f63d6c8af0fbb7ea9973b300f4bf335f64417c3bc8aa5381b7d3088
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user