Prime 3 opzioni
This commit is contained in:
parent
cbf1ec3c38
commit
c92496d0b5
56
Dispenser.cs
56
Dispenser.cs
@ -1,5 +1,61 @@
|
||||
namespace dispenser_sapone;
|
||||
|
||||
class Dispenser {
|
||||
string tipologia;
|
||||
double capienza;
|
||||
double quantitàErogata;
|
||||
double quantitàContenuta;
|
||||
|
||||
public Dispenser(string p_tipologia, double p_quantitàErogata, double p_quantitàContenuta, double p_capienza) {
|
||||
this.tipologia = p_tipologia;
|
||||
this.quantitàErogata = p_quantitàErogata;
|
||||
this.quantitàContenuta = p_quantitàContenuta;
|
||||
this.capienza = p_capienza;
|
||||
}
|
||||
|
||||
public void SetQuantitàErogata(double p_quantitàErogata) {
|
||||
this.quantitàErogata = p_quantitàErogata;
|
||||
}
|
||||
|
||||
public string GetTipologia() {
|
||||
return this.tipologia;
|
||||
}
|
||||
|
||||
public double GetQuantitàErogata() {
|
||||
return this.quantitàErogata;
|
||||
}
|
||||
|
||||
public double GetCapienza() {
|
||||
return this.capienza;
|
||||
}
|
||||
|
||||
public double GetQuantitàContenuta() {
|
||||
return this.quantitàContenuta;
|
||||
}
|
||||
|
||||
public void StampaDispenser() {
|
||||
Console.WriteLine($"Tipologia: {this.GetTipologia()}");
|
||||
Console.WriteLine($"Capienza: {this.GetCapienza()}");
|
||||
Console.WriteLine($"Quantità erogata: {this.GetQuantitàErogata()}");
|
||||
Console.WriteLine($"Quantità contenuta: {this.GetQuantitàContenuta()}");
|
||||
}
|
||||
|
||||
public void Erogazione() {
|
||||
if (this.quantitàContenuta - this.quantitàErogata <= 0) {
|
||||
|
||||
}
|
||||
this.quantitàContenuta = this.quantitàContenuta - this.quantitàErogata;
|
||||
}
|
||||
|
||||
public double Riempimento(double p_refill) {
|
||||
double ritorno;
|
||||
if (this.quantitàContenuta + p_refill > this.capienza) {
|
||||
ritorno = this.quantitàContenuta + p_refill - this.capienza;
|
||||
}
|
||||
else {
|
||||
this.quantitàContenuta = this.quantitàContenuta + p_refill;
|
||||
ritorno = this.quantitàContenuta;
|
||||
}
|
||||
return ritorno;
|
||||
}
|
||||
}
|
||||
104
Program.cs
104
Program.cs
@ -1,9 +1,103 @@
|
||||
namespace dispenser_sapone;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello, World!");
|
||||
class Program {
|
||||
static void Main(string[] args) {
|
||||
Console.Clear();
|
||||
//valori dispenser
|
||||
const string TIPOLOGIA1 = "Standard";
|
||||
const string TIPOLOGIA2 = "Custom";
|
||||
//valori standard
|
||||
const double CAPIENZA = 500;
|
||||
const double EROGAZIONE = 10;
|
||||
double quantitàErogata, quantitàContenuta, capienza;
|
||||
int scelta, input, i = 0;
|
||||
Dispenser[] dispensers = null;
|
||||
|
||||
Console.Write("Quanti dispenser considerare? ");
|
||||
input = Convert.ToInt32(Console.ReadLine());
|
||||
dispensers = new Dispenser[input];
|
||||
|
||||
do {
|
||||
Console.WriteLine("Inserire un'opzione:");
|
||||
Console.WriteLine("1. Crea dispenser standard");
|
||||
Console.WriteLine("2. Crea dispenser custom");
|
||||
Console.WriteLine("3. Mostra dispenser");
|
||||
Console.WriteLine("4. Erogazione");
|
||||
Console.WriteLine("5. Riempimento");
|
||||
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(TIPOLOGIA1, EROGAZIONE, CAPIENZA, CAPIENZA);
|
||||
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(TIPOLOGIA2, quantitàErogata, quantitàContenuta, capienza);
|
||||
i++;
|
||||
}
|
||||
Pausa();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
Console.Clear();
|
||||
for (int j = 0; j < dispensers.Length; j++) {
|
||||
Console.WriteLine($"Dispenser {j + 1}:");
|
||||
dispensers[j].StampaDispenser();
|
||||
Console.WriteLine();
|
||||
}
|
||||
Pausa();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
while (scelta != 0);
|
||||
}
|
||||
static void Pausa() {
|
||||
Console.WriteLine("Premere un tasto per continuare. . .");
|
||||
Console.ReadKey();
|
||||
Console.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
BIN
bin/Debug/net9.0/dispenser_sapone
Executable file
BIN
bin/Debug/net9.0/dispenser_sapone
Executable file
Binary file not shown.
23
bin/Debug/net9.0/dispenser_sapone.deps.json
Normal file
23
bin/Debug/net9.0/dispenser_sapone.deps.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v9.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v9.0": {
|
||||
"dispenser_sapone/1.0.0": {
|
||||
"runtime": {
|
||||
"dispenser_sapone.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"dispenser_sapone/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
bin/Debug/net9.0/dispenser_sapone.dll
Normal file
BIN
bin/Debug/net9.0/dispenser_sapone.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/dispenser_sapone.pdb
Normal file
BIN
bin/Debug/net9.0/dispenser_sapone.pdb
Normal file
Binary file not shown.
12
bin/Debug/net9.0/dispenser_sapone.runtimeconfig.json
Normal file
12
bin/Debug/net9.0/dispenser_sapone.runtimeconfig.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net9.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "9.0.0"
|
||||
},
|
||||
"configProperties": {
|
||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
|
||||
BIN
obj/Debug/net9.0/apphost
Executable file
BIN
obj/Debug/net9.0/apphost
Executable file
Binary file not shown.
22
obj/Debug/net9.0/dispenser_sapone.AssemblyInfo.cs
Normal file
22
obj/Debug/net9.0/dispenser_sapone.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("dispenser_sapone")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+cbf1ec3c38bb4c3492a74ebd2e4d930e5180714f")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("dispenser_sapone")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("dispenser_sapone")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
|
||||
@ -0,0 +1 @@
|
||||
e6431b311817db60eb5094c983152681b5926e4c01407422d780ffd52806cf09
|
||||
@ -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 = dispenser_sapone
|
||||
build_property.ProjectDir = /home/Verde/git/dispenser_sapone/
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||
build_property.EffectiveAnalysisLevelStyle = 9.0
|
||||
build_property.EnableCodeStyleSeverity =
|
||||
8
obj/Debug/net9.0/dispenser_sapone.GlobalUsings.g.cs
Normal file
8
obj/Debug/net9.0/dispenser_sapone.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/dispenser_sapone.assets.cache
Normal file
BIN
obj/Debug/net9.0/dispenser_sapone.assets.cache
Normal file
Binary file not shown.
@ -0,0 +1 @@
|
||||
23b31c6240ebc97540cb6a6c125a884f7e4d1e3050f5b750a75f4639532c37e1
|
||||
@ -0,0 +1,14 @@
|
||||
/home/Verde/git/dispenser_sapone/bin/Debug/net9.0/dispenser_sapone
|
||||
/home/Verde/git/dispenser_sapone/bin/Debug/net9.0/dispenser_sapone.deps.json
|
||||
/home/Verde/git/dispenser_sapone/bin/Debug/net9.0/dispenser_sapone.runtimeconfig.json
|
||||
/home/Verde/git/dispenser_sapone/bin/Debug/net9.0/dispenser_sapone.dll
|
||||
/home/Verde/git/dispenser_sapone/bin/Debug/net9.0/dispenser_sapone.pdb
|
||||
/home/Verde/git/dispenser_sapone/obj/Debug/net9.0/dispenser_sapone.GeneratedMSBuildEditorConfig.editorconfig
|
||||
/home/Verde/git/dispenser_sapone/obj/Debug/net9.0/dispenser_sapone.AssemblyInfoInputs.cache
|
||||
/home/Verde/git/dispenser_sapone/obj/Debug/net9.0/dispenser_sapone.AssemblyInfo.cs
|
||||
/home/Verde/git/dispenser_sapone/obj/Debug/net9.0/dispenser_sapone.csproj.CoreCompileInputs.cache
|
||||
/home/Verde/git/dispenser_sapone/obj/Debug/net9.0/dispenser_sapone.dll
|
||||
/home/Verde/git/dispenser_sapone/obj/Debug/net9.0/refint/dispenser_sapone.dll
|
||||
/home/Verde/git/dispenser_sapone/obj/Debug/net9.0/dispenser_sapone.pdb
|
||||
/home/Verde/git/dispenser_sapone/obj/Debug/net9.0/dispenser_sapone.genruntimeconfig.cache
|
||||
/home/Verde/git/dispenser_sapone/obj/Debug/net9.0/ref/dispenser_sapone.dll
|
||||
BIN
obj/Debug/net9.0/dispenser_sapone.dll
Normal file
BIN
obj/Debug/net9.0/dispenser_sapone.dll
Normal file
Binary file not shown.
1
obj/Debug/net9.0/dispenser_sapone.genruntimeconfig.cache
Normal file
1
obj/Debug/net9.0/dispenser_sapone.genruntimeconfig.cache
Normal file
@ -0,0 +1 @@
|
||||
896fe595a83715bb0d938308d7adaeab2df4894f7111fb44093aacfcb36a987b
|
||||
BIN
obj/Debug/net9.0/dispenser_sapone.pdb
Normal file
BIN
obj/Debug/net9.0/dispenser_sapone.pdb
Normal file
Binary file not shown.
BIN
obj/Debug/net9.0/ref/dispenser_sapone.dll
Normal file
BIN
obj/Debug/net9.0/ref/dispenser_sapone.dll
Normal file
Binary file not shown.
BIN
obj/Debug/net9.0/refint/dispenser_sapone.dll
Normal file
BIN
obj/Debug/net9.0/refint/dispenser_sapone.dll
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user