diff --git a/Program.cs b/Program.cs index 99ea032..972c7e5 100644 --- a/Program.cs +++ b/Program.cs @@ -1,9 +1,14 @@ -namespace vacanzeEstive_benzinaio; +using Microsoft.Win32.SafeHandles; + +namespace vacanzeEstive_benzinaio; class Program { static void Main(string[] args) { Console.Clear(); Rifornimento[] rifornimentos = CreaBenzinaio(); + Random r = new(); + int indiceUltimaPompaBenzina = TrovaIndiceUltimaPompaBenzina(rifornimentos); + int scelta = 0; do { @@ -21,6 +26,7 @@ class Program { case 0: break; case 1: + Pausa(); break; case 2: @@ -50,7 +56,7 @@ class Program { static Rifornimento[] CreaBenzinaio() { Random r = new(); - int totalePompe = r.Next(30); + int totalePompe = r.Next(1, 30); int totaleBenzina = r.Next(totalePompe); Rifornimento[] ritorno = new Rifornimento[totalePompe]; for (int i = 0; i < totaleBenzina; i++) { @@ -61,4 +67,15 @@ class Program { } return ritorno; } + + static int TrovaIndiceUltimaPompaBenzina(Rifornimento[] p_rifornimentos) { + int i; + bool exit = true; + for (i = 0; i < p_rifornimentos.Length && exit; i++) { + if (p_rifornimentos[i].GetTipoCarburante() == "gasolio") { + exit = false; + } + } + return i - 2; + } } diff --git a/Rifornimento.cs b/Rifornimento.cs index 148b27e..561b72e 100644 --- a/Rifornimento.cs +++ b/Rifornimento.cs @@ -27,4 +27,8 @@ class Rifornimento { public double GetCostoComplessivo() { return this.costoComplessivo; } + + public string GetTipoCarburante() { + return this.tipoCarburante; + } } \ No newline at end of file diff --git a/bin/Debug/net9.0/vacanzeEstive_benzinaio.dll b/bin/Debug/net9.0/vacanzeEstive_benzinaio.dll index c6a1390..3396886 100644 Binary files a/bin/Debug/net9.0/vacanzeEstive_benzinaio.dll and b/bin/Debug/net9.0/vacanzeEstive_benzinaio.dll differ diff --git a/bin/Debug/net9.0/vacanzeEstive_benzinaio.pdb b/bin/Debug/net9.0/vacanzeEstive_benzinaio.pdb index 38268ae..0981bbf 100644 Binary files a/bin/Debug/net9.0/vacanzeEstive_benzinaio.pdb and b/bin/Debug/net9.0/vacanzeEstive_benzinaio.pdb differ diff --git a/obj/Debug/net9.0/ref/vacanzeEstive_benzinaio.dll b/obj/Debug/net9.0/ref/vacanzeEstive_benzinaio.dll index f2690b3..716fa2a 100644 Binary files a/obj/Debug/net9.0/ref/vacanzeEstive_benzinaio.dll and b/obj/Debug/net9.0/ref/vacanzeEstive_benzinaio.dll differ diff --git a/obj/Debug/net9.0/refint/vacanzeEstive_benzinaio.dll b/obj/Debug/net9.0/refint/vacanzeEstive_benzinaio.dll index f2690b3..716fa2a 100644 Binary files a/obj/Debug/net9.0/refint/vacanzeEstive_benzinaio.dll and b/obj/Debug/net9.0/refint/vacanzeEstive_benzinaio.dll differ diff --git a/obj/Debug/net9.0/vacanzeEstive_benzinaio.AssemblyInfo.cs b/obj/Debug/net9.0/vacanzeEstive_benzinaio.AssemblyInfo.cs index 140b12f..6cd7086 100644 --- a/obj/Debug/net9.0/vacanzeEstive_benzinaio.AssemblyInfo.cs +++ b/obj/Debug/net9.0/vacanzeEstive_benzinaio.AssemblyInfo.cs @@ -13,10 +13,10 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("vacanzeEstive_benzinaio")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+93ab8537036568c5b13e687e9839a4e6f10acbf5")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+66abb93ec7d368cd60d47c8892b1d7163d386477")] [assembly: System.Reflection.AssemblyProductAttribute("vacanzeEstive_benzinaio")] [assembly: System.Reflection.AssemblyTitleAttribute("vacanzeEstive_benzinaio")] [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/vacanzeEstive_benzinaio.AssemblyInfoInputs.cache b/obj/Debug/net9.0/vacanzeEstive_benzinaio.AssemblyInfoInputs.cache index a8a37ce..cfc3534 100644 --- a/obj/Debug/net9.0/vacanzeEstive_benzinaio.AssemblyInfoInputs.cache +++ b/obj/Debug/net9.0/vacanzeEstive_benzinaio.AssemblyInfoInputs.cache @@ -1 +1 @@ -c81342749c4fd9b126ec8878e8d080e66f2635a2ab27b602a74a94a2dbc7d621 +8fbc40964bd836344ae2e0f035a3687ced9a797d3d0a6c1ea33335f3a20553df diff --git a/obj/Debug/net9.0/vacanzeEstive_benzinaio.dll b/obj/Debug/net9.0/vacanzeEstive_benzinaio.dll index c6a1390..3396886 100644 Binary files a/obj/Debug/net9.0/vacanzeEstive_benzinaio.dll and b/obj/Debug/net9.0/vacanzeEstive_benzinaio.dll differ diff --git a/obj/Debug/net9.0/vacanzeEstive_benzinaio.pdb b/obj/Debug/net9.0/vacanzeEstive_benzinaio.pdb index 38268ae..0981bbf 100644 Binary files a/obj/Debug/net9.0/vacanzeEstive_benzinaio.pdb and b/obj/Debug/net9.0/vacanzeEstive_benzinaio.pdb differ