Skip to content

Commit

Permalink
fix application
Browse files Browse the repository at this point in the history
  • Loading branch information
Sed-93 committed Jan 17, 2024
1 parent fe585f8 commit a1722e1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 7 additions & 1 deletion Personummer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ public static class PersonligInfoValidator
{
public static bool Validera(string personnummer)
{
// Kontrollerar så att personnummersinmatningen inte är null
if (personnummer == null)
{
return false;
}

// Kontrollera om personnumret har rätt längd.
if (personnummer.Length != 10 && personnummer.Length != 12)
{
Expand Down Expand Up @@ -33,7 +39,7 @@ public static bool Validera(string personnummer)
}
}


// Ytterligare kontroller för personnummer kan läggas till här.

return true;
Expand Down
3 changes: 2 additions & 1 deletion gruppuppgiftCI_CD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<StartupObject>PersonligVerifiering.Program</StartupObject>
</PropertyGroup>

<ItemGroup>
Expand All @@ -22,4 +23,4 @@
</PackageReference>
</ItemGroup>

</Project>
</Project>
8 changes: 4 additions & 4 deletions program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ class Program
{
static void Main()
{
Console.WriteLine("Skriv in ditt personnummer: ");
string personnummer = Console.ReadLine();
Console.WriteLine("Skriv in ditt personnummer (YYMMDD-XXXX): ");
string input = Console.ReadLine() ?? string.Empty;

if (PersonligInfoValidator.Validera(personnummer))
if (PersonligInfoValidator.Validera(input))
{
Console.WriteLine("Personnumret är giltigt.");

string kon = PersonligInfoValidator.HamtaKon(personnummer);
string kon = PersonligInfoValidator.HamtaKon(input);
Console.WriteLine($"Kön: {kon}");
}
else
Expand Down

0 comments on commit a1722e1

Please sign in to comment.