From 317b613312329b582f822dd00ca8e4b8150ffbcd Mon Sep 17 00:00:00 2001 From: victorbrandaao Date: Mon, 4 Nov 2024 12:06:15 -0300 Subject: [PATCH] =?UTF-8?q?Adi=C3=A7=C3=A3o=20de=20um=20novo=20m=C3=A9todo?= =?UTF-8?q?=20IsValidCompe=20no=20arquivo=20Program.cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.idea/.idea.ConsoleApp/.idea/.gitignore | 13 ++++++++++++ .../.idea/.idea.ConsoleApp/.idea/vcs.xml | 4 ++++ examples/dotnet/Program.cs | 21 +++++++++++++++---- 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 examples/dotnet/.idea/.idea.ConsoleApp/.idea/.gitignore create mode 100644 examples/dotnet/.idea/.idea.ConsoleApp/.idea/vcs.xml diff --git a/examples/dotnet/.idea/.idea.ConsoleApp/.idea/.gitignore b/examples/dotnet/.idea/.idea.ConsoleApp/.idea/.gitignore new file mode 100644 index 00000000..f83828bf --- /dev/null +++ b/examples/dotnet/.idea/.idea.ConsoleApp/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/modules.xml +/contentModel.xml +/.idea.ConsoleApp.iml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/examples/dotnet/.idea/.idea.ConsoleApp/.idea/vcs.xml b/examples/dotnet/.idea/.idea.ConsoleApp/.idea/vcs.xml new file mode 100644 index 00000000..d843f340 --- /dev/null +++ b/examples/dotnet/.idea/.idea.ConsoleApp/.idea/vcs.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/examples/dotnet/Program.cs b/examples/dotnet/Program.cs index baaebea2..156fb88e 100644 --- a/examples/dotnet/Program.cs +++ b/examples/dotnet/Program.cs @@ -1,3 +1,4 @@ + namespace ConsoleApp { using System; @@ -40,10 +41,21 @@ static void Main() /// to ensure that the input meets the expected format of a 3-digit code. /// private static string GetCompeFromUser() - { - Console.Write("Buscar COMPE (3 dígitos): "); - return Console.ReadLine(); - } +{ + string compe; + do + { + Console.Write("Buscar COMPE (3 dígitos): "); + compe = Console.ReadLine(); + } while (!IsValidCompe(compe)); + + return compe; +} + +private static bool IsValidCompe(string compe) +{ + return compe.Length == 3 && compe.All(char.IsDigit); +} /// /// Displays information about the banks in the collection. @@ -130,3 +142,4 @@ private static void FilterBanks(string compe) } } } +