Creazione benzinaio
This commit is contained in:
parent
66abb93ec7
commit
65ca5953b4
21
Program.cs
21
Program.cs
@ -1,9 +1,14 @@
|
|||||||
namespace vacanzeEstive_benzinaio;
|
using Microsoft.Win32.SafeHandles;
|
||||||
|
|
||||||
|
namespace vacanzeEstive_benzinaio;
|
||||||
|
|
||||||
class Program {
|
class Program {
|
||||||
static void Main(string[] args) {
|
static void Main(string[] args) {
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
Rifornimento[] rifornimentos = CreaBenzinaio();
|
Rifornimento[] rifornimentos = CreaBenzinaio();
|
||||||
|
Random r = new();
|
||||||
|
int indiceUltimaPompaBenzina = TrovaIndiceUltimaPompaBenzina(rifornimentos);
|
||||||
|
|
||||||
int scelta = 0;
|
int scelta = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -21,6 +26,7 @@ class Program {
|
|||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
@ -50,7 +56,7 @@ class Program {
|
|||||||
|
|
||||||
static Rifornimento[] CreaBenzinaio() {
|
static Rifornimento[] CreaBenzinaio() {
|
||||||
Random r = new();
|
Random r = new();
|
||||||
int totalePompe = r.Next(30);
|
int totalePompe = r.Next(1, 30);
|
||||||
int totaleBenzina = r.Next(totalePompe);
|
int totaleBenzina = r.Next(totalePompe);
|
||||||
Rifornimento[] ritorno = new Rifornimento[totalePompe];
|
Rifornimento[] ritorno = new Rifornimento[totalePompe];
|
||||||
for (int i = 0; i < totaleBenzina; i++) {
|
for (int i = 0; i < totaleBenzina; i++) {
|
||||||
@ -61,4 +67,15 @@ class Program {
|
|||||||
}
|
}
|
||||||
return ritorno;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,4 +27,8 @@ class Rifornimento {
|
|||||||
public double GetCostoComplessivo() {
|
public double GetCostoComplessivo() {
|
||||||
return this.costoComplessivo;
|
return this.costoComplessivo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetTipoCarburante() {
|
||||||
|
return this.tipoCarburante;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,10 +13,10 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("vacanzeEstive_benzinaio")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("vacanzeEstive_benzinaio")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[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.AssemblyProductAttribute("vacanzeEstive_benzinaio")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("vacanzeEstive_benzinaio")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("vacanzeEstive_benzinaio")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
||||||
// Generated by the MSBuild WriteCodeFragment class.
|
// Generato dalla classe WriteCodeFragment di MSBuild.
|
||||||
|
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
c81342749c4fd9b126ec8878e8d080e66f2635a2ab27b602a74a94a2dbc7d621
|
8fbc40964bd836344ae2e0f035a3687ced9a797d3d0a6c1ea33335f3a20553df
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user