diff --git a/Program.cs b/Program.cs index 15fb15f..dab8625 100644 --- a/Program.cs +++ b/Program.cs @@ -1,9 +1,129 @@ namespace biblioteca; -class Program -{ - static void Main(string[] args) - { - Console.WriteLine("Hello, World!"); +class Program { + static void Main(string[] args) { + Console.Clear(); + double quantitàErogata, quantitàContenuta, capienza, quantitàRimasta, quantitàRiempimento; + int scelta, input, i = 0; + Dispenser[] dispensers; + bool oggettoEsistente; + (double, bool) ritornoRiempimento; + Dispenser elementoRiempimento; + + Console.Write("Quanti dispenser considerare? "); + input = Convert.ToInt32(Console.ReadLine()); + dispensers = new Dispenser[input]; + + do { + Console.WriteLine("Inserire un'opzione:"); + Console.WriteLine("1. Crea biblioteca"); + Console.WriteLine("2. Mostra biblioteca"); + Console.WriteLine("3. Mostra libro"); + Console.WriteLine("4. Applca sconto"); + Console.WriteLine("0. Esci"); + Console.Write("Scelta: "); + scelta = Convert.ToInt32(Console.ReadLine()); + + switch (scelta) { + case 0: + break; + case 1: + Console.Clear(); + if (i > dispensers.Length - 1) { + Console.WriteLine($"Errore: non si possono creare più di {dispensers.Length} dispensers."); + } + else { + dispensers[i] = new Dispenser(); + i++; + Console.WriteLine("Dispenser standard creato."); + } + Pausa(); + break; + case 2: + Console.Clear(); + if (i > dispensers.Length - 1) { + Console.WriteLine($"Errore: non si possono creare più di {dispensers.Length} dispensers."); + } + else { + do { + Console.Write("Inserire la capienza del dispenser: "); + capienza = Convert.ToDouble(Console.ReadLine()); + if (capienza <= 0) { + 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(); + break; + + case 3: + Console.Clear(); + oggettoEsistente = true; + for (int j = 0; j < dispensers.Length && oggettoEsistente; j++) { + if (dispensers[j] == null) { + oggettoEsistente = false; + } + } + if (!oggettoEsistente) { + Console.WriteLine("Errore: è necessario creare *tutti* i dispenser prima di mostrarli."); + } + else { + for (int j = 0; j < dispensers.Length; j++) { + Console.WriteLine($"Dispenser {j + 1}:"); + dispensers[j].StampaDispenser(); + Console.WriteLine(); + } + } + Pausa(); + break; + + case 4: + Console.Clear(); + quantitàRimasta = SelezionaDispenser(dispensers).Erogazione(); + if (quantitàRimasta == 0) { + Console.WriteLine("Il dispenser è vuoto."); + } + else { + Console.WriteLine($"Quantità rimasta: {quantitàRimasta}"); + } + Console.WriteLine("Erogazione effettuata"); + Console.WriteLine(); + Pausa(); + break; + default: + Console.WriteLine("Opzione non valida."); + Pausa(); + break; + } + + } + while (scelta != 0); + } + + static void Pausa() { + Console.WriteLine("Premere un tasto per continuare. . ."); + Console.ReadKey(); + Console.Clear(); } } diff --git a/obj/Debug/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.cs b/obj/Debug/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.cs new file mode 100644 index 0000000..9e76325 --- /dev/null +++ b/obj/Debug/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")] diff --git a/obj/Debug/net9.0/biblioteca.AssemblyInfo.cs b/obj/Debug/net9.0/biblioteca.AssemblyInfo.cs new file mode 100644 index 0000000..dce2b3f --- /dev/null +++ b/obj/Debug/net9.0/biblioteca.AssemblyInfo.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("biblioteca")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+3a03e615888527814e42096963631995b875d7f7")] +[assembly: System.Reflection.AssemblyProductAttribute("biblioteca")] +[assembly: System.Reflection.AssemblyTitleAttribute("biblioteca")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/obj/Debug/net9.0/biblioteca.AssemblyInfoInputs.cache b/obj/Debug/net9.0/biblioteca.AssemblyInfoInputs.cache new file mode 100644 index 0000000..87bdd41 --- /dev/null +++ b/obj/Debug/net9.0/biblioteca.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +459e7955ba4252a3be22397cd3b5e71c5d58d11d307354d6993334cac373adf2 diff --git a/obj/Debug/net9.0/biblioteca.GeneratedMSBuildEditorConfig.editorconfig b/obj/Debug/net9.0/biblioteca.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 0000000..df519d8 --- /dev/null +++ b/obj/Debug/net9.0/biblioteca.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,15 @@ +is_global = true +build_property.TargetFramework = net9.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = biblioteca +build_property.ProjectDir = /home/Verde/git/biblioteca/ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.EffectiveAnalysisLevelStyle = 9.0 +build_property.EnableCodeStyleSeverity = diff --git a/obj/Debug/net9.0/biblioteca.GlobalUsings.g.cs b/obj/Debug/net9.0/biblioteca.GlobalUsings.g.cs new file mode 100644 index 0000000..8578f3d --- /dev/null +++ b/obj/Debug/net9.0/biblioteca.GlobalUsings.g.cs @@ -0,0 +1,8 @@ +// +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/obj/Debug/net9.0/biblioteca.assets.cache b/obj/Debug/net9.0/biblioteca.assets.cache new file mode 100644 index 0000000..442dc6f Binary files /dev/null and b/obj/Debug/net9.0/biblioteca.assets.cache differ