Skip to content

Commit

Permalink
Adição de um novo método IsValidCompe no arquivo Program.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
victorbrandaao committed Nov 4, 2024
1 parent ef87aa5 commit 317b613
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
13 changes: 13 additions & 0 deletions examples/dotnet/.idea/.idea.ConsoleApp/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions examples/dotnet/.idea/.idea.ConsoleApp/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 17 additions & 4 deletions examples/dotnet/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

namespace ConsoleApp
{
using System;
Expand Down Expand Up @@ -40,10 +41,21 @@ static void Main()
/// to ensure that the input meets the expected format of a 3-digit code.
/// </remarks>
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);
}

/// <summary>
/// Displays information about the banks in the collection.
Expand Down Expand Up @@ -130,3 +142,4 @@ private static void FilterBanks(string compe)
}
}
}

0 comments on commit 317b613

Please sign in to comment.