diff --git a/Program.cs b/Program.cs index 6822aca..e6399ee 100644 --- a/Program.cs +++ b/Program.cs @@ -56,7 +56,18 @@ class Program { break; case 4: Console.Clear(); - //Input4(); + Console.WriteLine("È richiesta la frase in cui effettuare la ricerca"); + stringa1 = Input(); + Console.WriteLine(); + Console.WriteLine("È richiesta la frase che verrà sostituita"); + stringa2 = Input(); + Console.WriteLine(); + if (Controllo2(stringa2, stringa1.Length)) { + Console.WriteLine(TrovaESostituisci(stringa1, stringa2)); + } + else { + Console.WriteLine($"Errore: la frase da cercare non può essere più lunga della frase in cui cercare"); + } Pausa(); break; case 5: @@ -166,4 +177,24 @@ class Program { return string.Join(" ", substrings); } + + static string TrovaESostituisci(string p_stringa1, string p_stringa2) { + string ritorno; + const string sostituisci = "*"; + + if (p_stringa1.Contains(p_stringa2)) { + ritorno = p_stringa1; + for (int i = 0; i < p_stringa2.Length; i++) { + ritorno = ritorno.Replace(p_stringa2[i], Convert.ToChar(sostituisci)); + } + + } + else { + ritorno = $"Nessuna occorrenza di {p_stringa2} trovata in {p_stringa1}"; + } + + return ritorno; + } + + } diff --git a/bin/Debug/net9.0/strings_3.dll b/bin/Debug/net9.0/strings_3.dll index c26ffef..3e4cb71 100644 Binary files a/bin/Debug/net9.0/strings_3.dll and b/bin/Debug/net9.0/strings_3.dll differ diff --git a/bin/Debug/net9.0/strings_3.pdb b/bin/Debug/net9.0/strings_3.pdb index 2152a9d..fe88fc7 100644 Binary files a/bin/Debug/net9.0/strings_3.pdb and b/bin/Debug/net9.0/strings_3.pdb differ diff --git a/obj/Debug/net9.0/ref/strings_3.dll b/obj/Debug/net9.0/ref/strings_3.dll index b9ab9a2..0f2bd7a 100644 Binary files a/obj/Debug/net9.0/ref/strings_3.dll and b/obj/Debug/net9.0/ref/strings_3.dll differ diff --git a/obj/Debug/net9.0/refint/strings_3.dll b/obj/Debug/net9.0/refint/strings_3.dll index b9ab9a2..0f2bd7a 100644 Binary files a/obj/Debug/net9.0/refint/strings_3.dll and b/obj/Debug/net9.0/refint/strings_3.dll differ diff --git a/obj/Debug/net9.0/strings_3.AssemblyInfo.cs b/obj/Debug/net9.0/strings_3.AssemblyInfo.cs index 9b559bf..ae9f6b9 100644 --- a/obj/Debug/net9.0/strings_3.AssemblyInfo.cs +++ b/obj/Debug/net9.0/strings_3.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("strings_3")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9786e2adcd46bff810419c77a664ff038d4fb2bd")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6415a06c85cfa74b112fb81faf09820fc9a42aaf")] [assembly: System.Reflection.AssemblyProductAttribute("strings_3")] [assembly: System.Reflection.AssemblyTitleAttribute("strings_3")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/obj/Debug/net9.0/strings_3.AssemblyInfoInputs.cache b/obj/Debug/net9.0/strings_3.AssemblyInfoInputs.cache index a0c2987..4e9c5da 100644 --- a/obj/Debug/net9.0/strings_3.AssemblyInfoInputs.cache +++ b/obj/Debug/net9.0/strings_3.AssemblyInfoInputs.cache @@ -1 +1 @@ -62074303f49b761550171178f383c453b8b19d1e02f472014128ddf26529322b +daf4d26f162aad74b0d6ca9d5e46d1f534c7df8294bd270db72667436b646006 diff --git a/obj/Debug/net9.0/strings_3.dll b/obj/Debug/net9.0/strings_3.dll index c26ffef..3e4cb71 100644 Binary files a/obj/Debug/net9.0/strings_3.dll and b/obj/Debug/net9.0/strings_3.dll differ diff --git a/obj/Debug/net9.0/strings_3.pdb b/obj/Debug/net9.0/strings_3.pdb index 2152a9d..fe88fc7 100644 Binary files a/obj/Debug/net9.0/strings_3.pdb and b/obj/Debug/net9.0/strings_3.pdb differ