Opzione 0 e menù
This commit is contained in:
parent
3a03e61588
commit
5b11eed20b
130
Program.cs
130
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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
|
||||
22
obj/Debug/net9.0/biblioteca.AssemblyInfo.cs
Normal file
22
obj/Debug/net9.0/biblioteca.AssemblyInfo.cs
Normal file
@ -0,0 +1,22 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
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.
|
||||
|
||||
1
obj/Debug/net9.0/biblioteca.AssemblyInfoInputs.cache
Normal file
1
obj/Debug/net9.0/biblioteca.AssemblyInfoInputs.cache
Normal file
@ -0,0 +1 @@
|
||||
459e7955ba4252a3be22397cd3b5e71c5d58d11d307354d6993334cac373adf2
|
||||
@ -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 =
|
||||
8
obj/Debug/net9.0/biblioteca.GlobalUsings.g.cs
Normal file
8
obj/Debug/net9.0/biblioteca.GlobalUsings.g.cs
Normal file
@ -0,0 +1,8 @@
|
||||
// <auto-generated/>
|
||||
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;
|
||||
BIN
obj/Debug/net9.0/biblioteca.assets.cache
Normal file
BIN
obj/Debug/net9.0/biblioteca.assets.cache
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user