diff --git a/Program.cs b/Program.cs index 6610b53..aa81ebc 100644 --- a/Program.cs +++ b/Program.cs @@ -1,9 +1,197 @@ -namespace matrix_4; +using System.Net; + +namespace matrix_4; + +class Program { + static void Main(string[] args) { + Console.Clear(); + int scelta, lineaAutobus, fermataAutobus; + (string[], string[], bool[,]) configurazione = Configurazione(); + string[] fermateAutobus = configurazione.Item1, lineeAutobus= configurazione.Item2; + bool[,] corrispondenzaLineaFermata = configurazione.Item3; + + + do { + Console.WriteLine("Debug: corrispondenzaLineaFermata"); + MostraMatrice(corrispondenzaLineaFermata); + Console.WriteLine("Inserire un'opzione:"); + Console.WriteLine("1. La linea passa per la fermata?"); + Console.WriteLine("2. Quali linee passano per la fermata?"); + Console.WriteLine("3. Quali e quante sono le fermate per la linea?"); + Console.WriteLine("4. Due linee hanno fermate in comune?"); + Console.WriteLine("5. oh hell nah"); + Console.WriteLine("0. Esci"); + Console.Write("Scelta: "); + scelta = Convert.ToInt32(Console.ReadLine()); + + switch (scelta) { + case 0: + break; + case 1: + Console.Clear(); + lineaAutobus = SelezionaElementoArray(lineeAutobus); + fermataAutobus = SelezionaElementoArray(fermateAutobus); + + if (corrispondenzaLineaFermata[lineaAutobus, fermataAutobus]) { + Console.WriteLine($"La linea {lineeAutobus[lineaAutobus]} passa per la fermata {fermateAutobus[fermataAutobus]}"); + } + else { + Console.WriteLine($"La linea {lineeAutobus[lineaAutobus]} non passa per la fermata {fermateAutobus[fermataAutobus]}"); + } + Pausa(); + break; + case 2: + Console.Clear(); + fermataAutobus = SelezionaElementoArray(fermateAutobus); + + Console.WriteLine($"Per la fermata {fermateAutobus[fermataAutobus]} passano le linee:"); + for (int i = 0; i < corrispondenzaLineaFermata.GetLength(1); i++) { + if (corrispondenzaLineaFermata[fermataAutobus, i]) { + Console.WriteLine(lineeAutobus[i]); + } + } + Pausa(); + break; + case 3: + Console.Clear(); + + Pausa(); + break; + case 4: + Console.Clear(); + Pausa(); + break; + case 5: + Console.Clear(); + Pausa(); + break; + + } + } + while (scelta != 0); + + + } + + static void MostraMatrice(bool[,] p_matrice) { + for (int r = 0; r < p_matrice.GetLength(0); r++) { + for (int c = 0; c < p_matrice.GetLength(1); c++) { + Console.Write(p_matrice[r, c] + " "); + } + Console.WriteLine(); + } + } + + static void Pausa() { + Console.WriteLine("Premere un tasto per continuare. . ."); + Console.ReadKey(); + Console.Clear(); + } + + static (string[], string[], bool[,]) Configurazione() { + int dimensione1, dimensione2, r = 0, c = 0, scelta; + (string[], string[], bool[,]) ritorno; + + Console.Clear(); + do { + Console.Write("Quante sono le fermate dell'autobus? "); + dimensione1 = Convert.ToInt32(Console.ReadLine()); + if (dimensione1 <= 0) { + Console.WriteLine("Errore: non è possibile inserire un numero minore o uguale a zero."); + Pausa(); + } + } + while (dimensione1 <= 0); + ritorno.Item1 = new string[dimensione1]; + for (int i = 0; i < dimensione1; i++) { + Console.Write($"Inserire la fermata n. {i + 1}: "); + ritorno.Item1[i] = Console.ReadLine(); + } + + Console.Clear(); + + do { + Console.Write("Quante sono le linee dell'autobus? "); + dimensione2 = Convert.ToInt32(Console.ReadLine()); + if (dimensione2 <= 0) { + Console.WriteLine("Errore: non è possibile inserire un numero minore o uguale a zero."); + Pausa(); + } + } + while (dimensione2 <= 0); + ritorno.Item2 = new string[dimensione2]; + for (int i = 0; i < dimensione2; i++) { + Console.Write($"Inserire la linea n. {i + 1}: "); + ritorno.Item2[i] = Console.ReadLine(); + } + + ritorno.Item3 = new bool[dimensione1, dimensione2]; + + Console.Clear(); + + while (r < dimensione1) { + while (c < dimensione2) { + Console.WriteLine($"Debug: r: {r}\tc: {c}\t dimensione1: {dimensione1}\t dimensione2: {dimensione2}"); + Console.WriteLine($"La linea {ritorno.Item2[c]} si ferma alla fermata {ritorno.Item1[r]}?"); + Console.WriteLine("[0] Sì\t[1] No"); + scelta = Convert.ToInt32(Console.ReadLine()); + switch (scelta) { + case 0: + ritorno.Item3[r, c] = true; + c++; + Console.Clear(); + break; + case 1: + ritorno.Item3[r, c] = false; + c++; + Console.Clear(); + break; + default: + Console.WriteLine("Opzione non valida."); + Pausa(); + break; + } + } + r++; + c = 0; + } + return ritorno; + } + + static void StampaArray(string[] p_array) { + for (int j = 0; j < p_array.Length; j++) { + Console.WriteLine("Elemento " + j + ": " + p_array[j]); + } + } + + static void StampaArraySoloElementi(string[] p_array) { + for (int j = 0; j < p_array.Length; j++) { + Console.WriteLine(p_array[j]); + } + } + static int SelezionaElementoArray(string[] p_array) { + int ritorno; + do { + Console.WriteLine("Quale elemento selezionare?"); + StampaArray(p_array); + ritorno = Convert.ToInt32(Console.ReadLine()); + if (ritorno < 0 || ritorno > p_array.Length) { + Console.WriteLine("La scelta inserita non è valida."); + Pausa(); + } + } while (ritorno < 0 || ritorno > p_array.Length); + + return ritorno; + + } + + static void MostraLineeFermata(bool[,] p_matrice, int p_indiceFermata) { + bool[] ritorno = new bool[p_matrice.GetLength(1)]; + for (int i = 0; i < p_matrice.GetLength(1); i++) { + if (p_matrice[p_indiceFermata, i]) { + ritorno[i] = true; + } + } -class Program -{ - static void Main(string[] args) - { - Console.WriteLine("Hello, World!"); } } diff --git a/bin/Debug/net9.0/matrix_4 b/bin/Debug/net9.0/matrix_4 new file mode 100755 index 0000000..5ec34fa Binary files /dev/null and b/bin/Debug/net9.0/matrix_4 differ diff --git a/bin/Debug/net9.0/matrix_4.deps.json b/bin/Debug/net9.0/matrix_4.deps.json new file mode 100644 index 0000000..83bbef7 --- /dev/null +++ b/bin/Debug/net9.0/matrix_4.deps.json @@ -0,0 +1,23 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v9.0", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v9.0": { + "matrix_4/1.0.0": { + "runtime": { + "matrix_4.dll": {} + } + } + } + }, + "libraries": { + "matrix_4/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + } + } +} \ No newline at end of file diff --git a/bin/Debug/net9.0/matrix_4.dll b/bin/Debug/net9.0/matrix_4.dll new file mode 100644 index 0000000..d6771da Binary files /dev/null and b/bin/Debug/net9.0/matrix_4.dll differ diff --git a/bin/Debug/net9.0/matrix_4.pdb b/bin/Debug/net9.0/matrix_4.pdb new file mode 100644 index 0000000..45a33e6 Binary files /dev/null and b/bin/Debug/net9.0/matrix_4.pdb differ diff --git a/bin/Debug/net9.0/matrix_4.runtimeconfig.json b/bin/Debug/net9.0/matrix_4.runtimeconfig.json new file mode 100644 index 0000000..b19c3c8 --- /dev/null +++ b/bin/Debug/net9.0/matrix_4.runtimeconfig.json @@ -0,0 +1,12 @@ +{ + "runtimeOptions": { + "tfm": "net9.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "9.0.0" + }, + "configProperties": { + "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false + } + } +} \ No newline at end of file diff --git a/obj/Debug/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.cs b/obj/Debug/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.cs new file mode 100644 index 0000000..9e76325 --- /dev/null +++ b/obj/Debug/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")] diff --git a/obj/Debug/net9.0/apphost b/obj/Debug/net9.0/apphost new file mode 100755 index 0000000..5ec34fa Binary files /dev/null and b/obj/Debug/net9.0/apphost differ diff --git a/obj/Debug/net9.0/matrix_4.AssemblyInfo.cs b/obj/Debug/net9.0/matrix_4.AssemblyInfo.cs new file mode 100644 index 0000000..8843c2f --- /dev/null +++ b/obj/Debug/net9.0/matrix_4.AssemblyInfo.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("matrix_4")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a42c0b4ffd82a599b51f6765da5945ea7350602c")] +[assembly: System.Reflection.AssemblyProductAttribute("matrix_4")] +[assembly: System.Reflection.AssemblyTitleAttribute("matrix_4")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/obj/Debug/net9.0/matrix_4.AssemblyInfoInputs.cache b/obj/Debug/net9.0/matrix_4.AssemblyInfoInputs.cache new file mode 100644 index 0000000..4eec224 --- /dev/null +++ b/obj/Debug/net9.0/matrix_4.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +d061d27a38797d544dcf00937cd4c8003e45f3c6fe40193cae0f0c8b0bc62771 diff --git a/obj/Debug/net9.0/matrix_4.GeneratedMSBuildEditorConfig.editorconfig b/obj/Debug/net9.0/matrix_4.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 0000000..cbbb023 --- /dev/null +++ b/obj/Debug/net9.0/matrix_4.GeneratedMSBuildEditorConfig.editorconfig @@ -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 = matrix_4 +build_property.ProjectDir = /home/Verde/git/matrix_4/ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.EffectiveAnalysisLevelStyle = 9.0 +build_property.EnableCodeStyleSeverity = diff --git a/obj/Debug/net9.0/matrix_4.GlobalUsings.g.cs b/obj/Debug/net9.0/matrix_4.GlobalUsings.g.cs new file mode 100644 index 0000000..8578f3d --- /dev/null +++ b/obj/Debug/net9.0/matrix_4.GlobalUsings.g.cs @@ -0,0 +1,8 @@ +// +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; diff --git a/obj/Debug/net9.0/matrix_4.assets.cache b/obj/Debug/net9.0/matrix_4.assets.cache new file mode 100644 index 0000000..4e0798d Binary files /dev/null and b/obj/Debug/net9.0/matrix_4.assets.cache differ diff --git a/obj/Debug/net9.0/matrix_4.csproj.CoreCompileInputs.cache b/obj/Debug/net9.0/matrix_4.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..f26a58f --- /dev/null +++ b/obj/Debug/net9.0/matrix_4.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +9608c8ef14e9ba316fc42458522ae7c6f42771a0c1dedb67789fbf8695cb812b diff --git a/obj/Debug/net9.0/matrix_4.csproj.FileListAbsolute.txt b/obj/Debug/net9.0/matrix_4.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..ea14bfc --- /dev/null +++ b/obj/Debug/net9.0/matrix_4.csproj.FileListAbsolute.txt @@ -0,0 +1,14 @@ +/home/Verde/git/matrix_4/bin/Debug/net9.0/matrix_4 +/home/Verde/git/matrix_4/bin/Debug/net9.0/matrix_4.deps.json +/home/Verde/git/matrix_4/bin/Debug/net9.0/matrix_4.runtimeconfig.json +/home/Verde/git/matrix_4/bin/Debug/net9.0/matrix_4.dll +/home/Verde/git/matrix_4/bin/Debug/net9.0/matrix_4.pdb +/home/Verde/git/matrix_4/obj/Debug/net9.0/matrix_4.GeneratedMSBuildEditorConfig.editorconfig +/home/Verde/git/matrix_4/obj/Debug/net9.0/matrix_4.AssemblyInfoInputs.cache +/home/Verde/git/matrix_4/obj/Debug/net9.0/matrix_4.AssemblyInfo.cs +/home/Verde/git/matrix_4/obj/Debug/net9.0/matrix_4.csproj.CoreCompileInputs.cache +/home/Verde/git/matrix_4/obj/Debug/net9.0/matrix_4.dll +/home/Verde/git/matrix_4/obj/Debug/net9.0/refint/matrix_4.dll +/home/Verde/git/matrix_4/obj/Debug/net9.0/matrix_4.pdb +/home/Verde/git/matrix_4/obj/Debug/net9.0/matrix_4.genruntimeconfig.cache +/home/Verde/git/matrix_4/obj/Debug/net9.0/ref/matrix_4.dll diff --git a/obj/Debug/net9.0/matrix_4.dll b/obj/Debug/net9.0/matrix_4.dll new file mode 100644 index 0000000..d6771da Binary files /dev/null and b/obj/Debug/net9.0/matrix_4.dll differ diff --git a/obj/Debug/net9.0/matrix_4.genruntimeconfig.cache b/obj/Debug/net9.0/matrix_4.genruntimeconfig.cache new file mode 100644 index 0000000..6d8bb4c --- /dev/null +++ b/obj/Debug/net9.0/matrix_4.genruntimeconfig.cache @@ -0,0 +1 @@ +4f95fa8dc890848e7a8bfe126e89b34a58486b3d8b2f57a9a9f9eab0fc5429b4 diff --git a/obj/Debug/net9.0/matrix_4.pdb b/obj/Debug/net9.0/matrix_4.pdb new file mode 100644 index 0000000..45a33e6 Binary files /dev/null and b/obj/Debug/net9.0/matrix_4.pdb differ diff --git a/obj/Debug/net9.0/ref/matrix_4.dll b/obj/Debug/net9.0/ref/matrix_4.dll new file mode 100644 index 0000000..52845e1 Binary files /dev/null and b/obj/Debug/net9.0/ref/matrix_4.dll differ diff --git a/obj/Debug/net9.0/refint/matrix_4.dll b/obj/Debug/net9.0/refint/matrix_4.dll new file mode 100644 index 0000000..52845e1 Binary files /dev/null and b/obj/Debug/net9.0/refint/matrix_4.dll differ