Opzione 5 + default
This commit is contained in:
parent
ae01f25a36
commit
4112ded0ec
@ -65,15 +65,18 @@ class Dispenser {
|
||||
return ritorno;
|
||||
}
|
||||
|
||||
public double Riempimento(double p_refill) {
|
||||
public (double, bool) Riempimento(double p_refill) {
|
||||
double ritorno;
|
||||
bool overflow;
|
||||
if (this.quantitàContenuta + p_refill > this.capienza) {
|
||||
ritorno = this.quantitàContenuta + p_refill - this.capienza;
|
||||
overflow = true;
|
||||
}
|
||||
else {
|
||||
this.quantitàContenuta = this.quantitàContenuta + p_refill;
|
||||
ritorno = this.quantitàContenuta;
|
||||
overflow = false;
|
||||
}
|
||||
return ritorno;
|
||||
return (ritorno, overflow);
|
||||
}
|
||||
}
|
||||
35
Program.cs
35
Program.cs
@ -1,12 +1,16 @@
|
||||
namespace dispenser_sapone;
|
||||
using System.Reflection;
|
||||
|
||||
namespace dispenser_sapone;
|
||||
|
||||
class Program {
|
||||
static void Main(string[] args) {
|
||||
Console.Clear();
|
||||
double quantitàErogata, quantitàContenuta, capienza, quantitàRimasta;
|
||||
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());
|
||||
@ -110,6 +114,33 @@ class Program {
|
||||
Console.WriteLine();
|
||||
Pausa();
|
||||
break;
|
||||
case 5:
|
||||
Console.Clear();
|
||||
do {
|
||||
Console.Write("Inserire la quantità per riempire il dispenser: ");
|
||||
quantitàRiempimento = Convert.ToDouble(Console.ReadLine());
|
||||
if (quantitàRiempimento <= 0) {
|
||||
Console.WriteLine("Errore: la quantità per riempire il dispenser non può essere minore o uguale a zero.");
|
||||
}
|
||||
}
|
||||
while (quantitàRiempimento <= 0);
|
||||
elementoRiempimento = SelezionaDispenser(dispensers);
|
||||
ritornoRiempimento = elementoRiempimento.Riempimento(quantitàRiempimento);
|
||||
if (ritornoRiempimento.Item2 == true) {
|
||||
Console.WriteLine("Il dispenser è pieno.");
|
||||
Console.WriteLine($"Sono avanzati {ritornoRiempimento.Item1}ml di sapone");
|
||||
}
|
||||
else {
|
||||
Console.WriteLine($"Quantità corrente: {elementoRiempimento.GetQuantitàContenuta()}");
|
||||
}
|
||||
Console.WriteLine("Riempimento effettuato.");
|
||||
Pausa();
|
||||
break;
|
||||
|
||||
default:
|
||||
Console.WriteLine("Opzione non valida.");
|
||||
Pausa();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("dispenser_sapone")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c92496d0b5143b7a429033b8cd9a249053a08a75")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ae01f25a36cb1954228d7fdabc38a95fa5ec6c39")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("dispenser_sapone")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("dispenser_sapone")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@ -1 +1 @@
|
||||
a590da0f58f352d3ab954b67f58709ab6a266a4e1bc77c97eab6bb12202a17f9
|
||||
a104038d9fe2a848d76087c8e6f1098575f553ad58b7079338ebeec017dd8151
|
||||
|
||||
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