Opzione 3 e 6
This commit is contained in:
parent
389d4771ec
commit
25c50a4b8d
@ -1,6 +1,7 @@
|
|||||||
namespace ordini_ristorante;
|
namespace ordini_ristorante;
|
||||||
|
|
||||||
class Ordine {
|
class Ordine {
|
||||||
|
public static int codiceOrdineProgressivo = -1;
|
||||||
int codiceOrdine;
|
int codiceOrdine;
|
||||||
DateTime dataOrdine;
|
DateTime dataOrdine;
|
||||||
string cliente;
|
string cliente;
|
||||||
@ -11,10 +12,8 @@ class Ordine {
|
|||||||
this.codiceOrdine = p_codiceOrdine;
|
this.codiceOrdine = p_codiceOrdine;
|
||||||
this.dataOrdine = p_dataOrdine;
|
this.dataOrdine = p_dataOrdine;
|
||||||
this.cliente = p_cliente;
|
this.cliente = p_cliente;
|
||||||
this.piatti = piatti;
|
this.piatti = p_piatti;
|
||||||
this.stato = p_stato != "in preparazione" || p_stato != "pagato" || p_stato != "annullato"
|
this.stato = p_stato;
|
||||||
? throw new FormatException("Stato non valido")
|
|
||||||
: p_stato;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetCodiceOrdine() {
|
public int GetCodiceOrdine() {
|
||||||
|
|||||||
80
Program.cs
80
Program.cs
@ -21,7 +21,7 @@ class Program {
|
|||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
AggiungiPiatto(ristorante);
|
ristorante.AggiungiPiatto(CreaPiatto());
|
||||||
Console.WriteLine("Piatto aggiunto con successo");
|
Console.WriteLine("Piatto aggiunto con successo");
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
@ -30,6 +30,8 @@ class Program {
|
|||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
AggiungiOrdine(ristorante);
|
||||||
|
Console.WriteLine("Ordine aggiunto con successo");
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
@ -39,6 +41,7 @@ class Program {
|
|||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
|
StampaOrdini(ristorante);
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -59,7 +62,7 @@ class Program {
|
|||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AggiungiPiatto(Ristorante p_ristorante) {
|
static Piatto CreaPiatto() {
|
||||||
string nome;
|
string nome;
|
||||||
string descrizione;
|
string descrizione;
|
||||||
float prezzo = -1;
|
float prezzo = -1;
|
||||||
@ -86,9 +89,8 @@ class Program {
|
|||||||
}
|
}
|
||||||
while (prezzo < 0);
|
while (prezzo < 0);
|
||||||
|
|
||||||
p_ristorante.AggiungiPiatto(new Piatto(nome, descrizione, prezzo));
|
return new Piatto(nome, descrizione, prezzo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void StampaMenu(Ristorante p_ristorante) {
|
static void StampaMenu(Ristorante p_ristorante) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (Piatto p in p_ristorante.GetMenu()) {
|
foreach (Piatto p in p_ristorante.GetMenu()) {
|
||||||
@ -98,4 +100,74 @@ class Program {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void AggiungiOrdine(Ristorante p_ristorante) {
|
||||||
|
int codiceOrdine;
|
||||||
|
//DateTime dataOrdine;
|
||||||
|
string cliente;
|
||||||
|
Piatto[] piatti;
|
||||||
|
int numeroPiatti = -1, scelta = -1;
|
||||||
|
string stato;
|
||||||
|
|
||||||
|
Console.Write("Nome del cliente: ");
|
||||||
|
cliente = Console.ReadLine();
|
||||||
|
|
||||||
|
//Console.Write("Descrizione del piatto: ");
|
||||||
|
//descrizione = Console.ReadLine();
|
||||||
|
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
Console.Write("Quanti piatti ordinare? ");
|
||||||
|
numeroPiatti = Convert.ToInt32(Console.ReadLine());
|
||||||
|
if (numeroPiatti < 0) {
|
||||||
|
Console.WriteLine("Numero di piatti non valido.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (FormatException) {
|
||||||
|
Console.WriteLine("Numero di piatti non valido.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (numeroPiatti < 0);
|
||||||
|
|
||||||
|
piatti = new Piatto[numeroPiatti];
|
||||||
|
|
||||||
|
for (int i = 0; i < numeroPiatti; i++) {
|
||||||
|
Console.WriteLine($"Scelta del piatto n. {i + 1}\n");
|
||||||
|
Console.WriteLine("Quale piatto scegliere?");
|
||||||
|
StampaMenu(p_ristorante);
|
||||||
|
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
Console.Write("Scelta: ");
|
||||||
|
scelta = Convert.ToInt32(Console.ReadLine());
|
||||||
|
if (scelta <= 0 || scelta > p_ristorante.GetMenu().Length) {
|
||||||
|
Console.WriteLine("Scelta non valida.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (FormatException) {
|
||||||
|
Console.WriteLine("Scelta non valida.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (scelta <= 0 || scelta > p_ristorante.GetMenu().Length);
|
||||||
|
|
||||||
|
piatti[i] = p_ristorante.GetMenu()[scelta - 1];
|
||||||
|
}
|
||||||
|
codiceOrdine = Ordine.codiceOrdineProgressivo + 1;
|
||||||
|
Ordine.codiceOrdineProgressivo = codiceOrdine;
|
||||||
|
p_ristorante.AggiungiOrdine(new Ordine(codiceOrdine, DateTime.Now, cliente, piatti, "in preparazione"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void StampaOrdini(Ristorante p_ristorante) {
|
||||||
|
int i = 0;
|
||||||
|
foreach (Ordine o in p_ristorante.GetOrdini()) {
|
||||||
|
Console.WriteLine($"Ordine n. {i + 1}:");
|
||||||
|
o.StampaOrdine();
|
||||||
|
Console.WriteLine();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -13,10 +13,10 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("ordini_ristorante")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("ordini_ristorante")]
|
||||||
[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+b548480f07aff0b16f63b907bd44b887976e89eb")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+389d4771ec0493bd4e269a94942e65bc5b2be348")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("ordini_ristorante")]
|
[assembly: System.Reflection.AssemblyProductAttribute("ordini_ristorante")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("ordini_ristorante")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("ordini_ristorante")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
||||||
// Generato dalla classe WriteCodeFragment di MSBuild.
|
// Generated by the MSBuild WriteCodeFragment class.
|
||||||
|
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
d720b1271e49dc7c90fff3358be4316745aa45de2d86000c3c657a67e67a2db7
|
11d675b6b88938d237d510d4cd5a5d5d435c4050a48b7e13fa970f91acaeef88
|
||||||
|
|||||||
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