diff --git a/Program.cs b/Program.cs index 4aba63d..7ece043 100644 --- a/Program.cs +++ b/Program.cs @@ -1,9 +1,101 @@ namespace ordini_ristorante; -class Program -{ - static void Main(string[] args) - { - Console.WriteLine("Hello, World!"); +class Program { + static void Main(string[] args) { + Console.Clear(); + Ristorante ristorante = new(); + int scelta = -1; + do { + Console.WriteLine("Inserire un'opzione:"); + Console.WriteLine("1. Crea piatto"); + Console.WriteLine("2. Visualizza menù"); + Console.WriteLine("3. Crea ordine"); + Console.WriteLine("4. Annulla ordine"); + Console.WriteLine("5. Paga ordine"); + Console.WriteLine("6. Visualizza ordine"); + Console.WriteLine("0. Esci"); + Console.Write("Scelta: "); + try { + scelta = Convert.ToInt32(Console.ReadLine()); + switch (scelta) { + case 0: + break; + case 1: + AggiungiPiatto(ristorante); + Console.WriteLine("Piatto aggiunto con successo"); + Pausa(); + break; + case 2: + StampaMenu(ristorante); + Pausa(); + break; + case 3: + Pausa(); + break; + case 4: + Pausa(); + break; + case 5: + Pausa(); + break; + case 6: + Pausa(); + break; + default: + Console.WriteLine("Opzione non valida."); + Pausa(); + break; + } + } + catch (FormatException) { + Console.WriteLine("Opzione non valida."); + Pausa(); + } + } + while (scelta != 0); + } + static void Pausa() { + Console.WriteLine("Premere un tasto per continuare. . ."); + Console.ReadKey(); + } + + static void AggiungiPiatto(Ristorante p_ristorante) { + string nome; + string descrizione; + float prezzo = -1; + + Console.Write("Nome del piatto: "); + nome = Console.ReadLine(); + + Console.Write("Descrizione del piatto: "); + descrizione = Console.ReadLine(); + + do { + try { + Console.Write("Inserire il prezzo: "); + prezzo = (float)Convert.ToDouble(Console.ReadLine()); + if (prezzo < 0) { + Console.WriteLine("Prezzo non valido."); + Pausa(); + } + } + catch (FormatException) { + Console.WriteLine("Prezzo non valido."); + Pausa(); + } + } + while (prezzo < 0); + + p_ristorante.AggiungiPiatto(new Piatto(nome, descrizione, prezzo)); + } + + static void StampaMenu(Ristorante p_ristorante) { + int i = 0; + foreach (Piatto p in p_ristorante.GetMenu()) { + Console.WriteLine($"Piatto {i + 1}:"); + p.StampaPiatto(); + Console.WriteLine(); + i++; + } } } diff --git a/Ristorante.cs b/Ristorante.cs index 67c17fe..ba98e20 100644 --- a/Ristorante.cs +++ b/Ristorante.cs @@ -1,20 +1,35 @@ namespace ordini_ristorante; class Ristorante { - Piatto[] menu; - Ordine[] ordini; + Piatto[] menu = []; + Ordine[] ordini = []; + public Piatto[] GetMenu() { + return this.menu; + } + + public Ordine[] GetOrdini() { + return this.ordini; + } + + public void SetMenu(Piatto[] p_menu) { + this.menu = p_menu; + } + + public void SetOrdini(Ordine[] p_ordini) { + this.ordini = p_ordini; + } public void AggiungiPiatto(Piatto p_nuovoPiatto) { Piatto[] menuNuovo = new Piatto[this.menu.Length + 1]; this.menu.CopyTo(menuNuovo, 0); - menuNuovo[this.menu.Length + 1] = p_nuovoPiatto; + menuNuovo[menuNuovo.Length - 1] = p_nuovoPiatto; this.menu = menuNuovo; } public void AggiungiOrdine(Ordine p_nuovoOrdine) { Ordine[] ordiniNuovo = new Ordine[this.ordini.Length + 1]; this.ordini.CopyTo(ordiniNuovo, 0); - ordiniNuovo[this.ordini.Length + 1] = p_nuovoOrdine; + ordiniNuovo[ordiniNuovo.Length - 1] = p_nuovoOrdine; this.ordini = ordiniNuovo; } diff --git a/bin/Debug/net9.0/ordini_ristorante b/bin/Debug/net9.0/ordini_ristorante new file mode 100755 index 0000000..c846c52 Binary files /dev/null and b/bin/Debug/net9.0/ordini_ristorante differ diff --git a/bin/Debug/net9.0/ordini_ristorante.deps.json b/bin/Debug/net9.0/ordini_ristorante.deps.json new file mode 100644 index 0000000..a1e0482 --- /dev/null +++ b/bin/Debug/net9.0/ordini_ristorante.deps.json @@ -0,0 +1,23 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v9.0", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v9.0": { + "ordini_ristorante/1.0.0": { + "runtime": { + "ordini_ristorante.dll": {} + } + } + } + }, + "libraries": { + "ordini_ristorante/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + } + } +} \ No newline at end of file diff --git a/bin/Debug/net9.0/ordini_ristorante.dll b/bin/Debug/net9.0/ordini_ristorante.dll new file mode 100644 index 0000000..81003f8 Binary files /dev/null and b/bin/Debug/net9.0/ordini_ristorante.dll differ diff --git a/bin/Debug/net9.0/ordini_ristorante.pdb b/bin/Debug/net9.0/ordini_ristorante.pdb new file mode 100644 index 0000000..102ed94 Binary files /dev/null and b/bin/Debug/net9.0/ordini_ristorante.pdb differ diff --git a/bin/Debug/net9.0/ordini_ristorante.runtimeconfig.json b/bin/Debug/net9.0/ordini_ristorante.runtimeconfig.json new file mode 100644 index 0000000..b19c3c8 --- /dev/null +++ b/bin/Debug/net9.0/ordini_ristorante.runtimeconfig.json @@ -0,0 +1,12 @@ +{ + "runtimeOptions": { + "tfm": "net9.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "9.0.0" + }, + "configProperties": { + "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false + } + } +} \ No newline at end of file diff --git a/obj/Debug/net9.0/apphost b/obj/Debug/net9.0/apphost new file mode 100755 index 0000000..c846c52 Binary files /dev/null and b/obj/Debug/net9.0/apphost differ diff --git a/obj/Debug/net9.0/ordini_ristorante.AssemblyInfo.cs b/obj/Debug/net9.0/ordini_ristorante.AssemblyInfo.cs index 8e3c4b8..94e1b76 100644 --- a/obj/Debug/net9.0/ordini_ristorante.AssemblyInfo.cs +++ b/obj/Debug/net9.0/ordini_ristorante.AssemblyInfo.cs @@ -13,10 +13,10 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("ordini_ristorante")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+499cabf977087ed12801624d0d04a68163f62cae")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b548480f07aff0b16f63b907bd44b887976e89eb")] [assembly: System.Reflection.AssemblyProductAttribute("ordini_ristorante")] [assembly: System.Reflection.AssemblyTitleAttribute("ordini_ristorante")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] -// Generated by the MSBuild WriteCodeFragment class. +// Generato dalla classe WriteCodeFragment di MSBuild. diff --git a/obj/Debug/net9.0/ordini_ristorante.AssemblyInfoInputs.cache b/obj/Debug/net9.0/ordini_ristorante.AssemblyInfoInputs.cache index 31d2e02..cf725f2 100644 --- a/obj/Debug/net9.0/ordini_ristorante.AssemblyInfoInputs.cache +++ b/obj/Debug/net9.0/ordini_ristorante.AssemblyInfoInputs.cache @@ -1 +1 @@ -d602e9936fa4dbc102619157e087b18e15103db1cf02e8c19baf93d10a6e8ab1 +d720b1271e49dc7c90fff3358be4316745aa45de2d86000c3c657a67e67a2db7 diff --git a/obj/Debug/net9.0/ordini_ristorante.csproj.CoreCompileInputs.cache b/obj/Debug/net9.0/ordini_ristorante.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..a60e88c --- /dev/null +++ b/obj/Debug/net9.0/ordini_ristorante.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +21df64d530c2916de7570939bc7b9df9bcfb0b5d53b3a9decef760ed2cca8b29 diff --git a/obj/Debug/net9.0/ordini_ristorante.csproj.FileListAbsolute.txt b/obj/Debug/net9.0/ordini_ristorante.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..f6622cc --- /dev/null +++ b/obj/Debug/net9.0/ordini_ristorante.csproj.FileListAbsolute.txt @@ -0,0 +1,14 @@ +/home/Verde/git/ordini_ristorante/bin/Debug/net9.0/ordini_ristorante +/home/Verde/git/ordini_ristorante/bin/Debug/net9.0/ordini_ristorante.deps.json +/home/Verde/git/ordini_ristorante/bin/Debug/net9.0/ordini_ristorante.runtimeconfig.json +/home/Verde/git/ordini_ristorante/bin/Debug/net9.0/ordini_ristorante.dll +/home/Verde/git/ordini_ristorante/bin/Debug/net9.0/ordini_ristorante.pdb +/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ordini_ristorante.GeneratedMSBuildEditorConfig.editorconfig +/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ordini_ristorante.AssemblyInfoInputs.cache +/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ordini_ristorante.AssemblyInfo.cs +/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ordini_ristorante.csproj.CoreCompileInputs.cache +/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ordini_ristorante.dll +/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/refint/ordini_ristorante.dll +/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ordini_ristorante.pdb +/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ordini_ristorante.genruntimeconfig.cache +/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ref/ordini_ristorante.dll diff --git a/obj/Debug/net9.0/ordini_ristorante.dll b/obj/Debug/net9.0/ordini_ristorante.dll new file mode 100644 index 0000000..81003f8 Binary files /dev/null and b/obj/Debug/net9.0/ordini_ristorante.dll differ diff --git a/obj/Debug/net9.0/ordini_ristorante.genruntimeconfig.cache b/obj/Debug/net9.0/ordini_ristorante.genruntimeconfig.cache new file mode 100644 index 0000000..89fd7d2 --- /dev/null +++ b/obj/Debug/net9.0/ordini_ristorante.genruntimeconfig.cache @@ -0,0 +1 @@ +f3dc620128d63ccb502ec85787876a8041f1bc1813b22fa68306e53e67b503ab diff --git a/obj/Debug/net9.0/ordini_ristorante.pdb b/obj/Debug/net9.0/ordini_ristorante.pdb new file mode 100644 index 0000000..102ed94 Binary files /dev/null and b/obj/Debug/net9.0/ordini_ristorante.pdb differ diff --git a/obj/Debug/net9.0/ref/ordini_ristorante.dll b/obj/Debug/net9.0/ref/ordini_ristorante.dll new file mode 100644 index 0000000..bf9ad85 Binary files /dev/null and b/obj/Debug/net9.0/ref/ordini_ristorante.dll differ diff --git a/obj/Debug/net9.0/refint/ordini_ristorante.dll b/obj/Debug/net9.0/refint/ordini_ristorante.dll new file mode 100644 index 0000000..bf9ad85 Binary files /dev/null and b/obj/Debug/net9.0/refint/ordini_ristorante.dll differ