Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Davlatshokh-Homework/Davlatshokh-Homework.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33815.320
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Davlatshokh-Homework", "Davlatshokh-Homework\Davlatshokh-Homework.csproj", "{1D51C5B4-3D00-40DF-94AA-E9DFBE1473A9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1D51C5B4-3D00-40DF-94AA-E9DFBE1473A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D51C5B4-3D00-40DF-94AA-E9DFBE1473A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D51C5B4-3D00-40DF-94AA-E9DFBE1473A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D51C5B4-3D00-40DF-94AA-E9DFBE1473A9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {21623937-3150-4973-8BEC-0E396046750A}
EndGlobalSection
EndGlobal
25 changes: 25 additions & 0 deletions Davlatshokh_Homeworks/Davlatshokh_Homeworks.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33815.320
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Davlatshokh_Homeworks", "Davlatshokh_Homeworks\Davlatshokh_Homeworks.csproj", "{80E6EADB-98D6-445D-800A-91B87B2225BA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{80E6EADB-98D6-445D-800A-91B87B2225BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80E6EADB-98D6-445D-800A-91B87B2225BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80E6EADB-98D6-445D-800A-91B87B2225BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80E6EADB-98D6-445D-800A-91B87B2225BA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {343DC8E0-1A66-4D1D-B102-A5ED73F08255}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework05
{
internal class InvalidPasswordException : Exception
{
public InvalidPasswordException(string MessageToUser)
: base(MessageToUser)
{

}

}
}
69 changes: 69 additions & 0 deletions Davlatshokh_Homeworks/Davlatshokh_Homeworks/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System.Globalization;
using System.Runtime.CompilerServices;

namespace Homework05
{
internal class Program
{
static void Main(string[] args)
{
try
{
Console.WriteLine("Please create Password to your account! ");
Thread.Sleep(500);
Console.Write("Password:");
string s = Console.ReadLine();
Password(s);
return;

}
catch (InvalidPasswordException ex)
{
Console.WriteLine("Sorry your password does not match the requirements \nIn your Password must exist \nMinimum 8 elements \nMinimum 1 number \nMinimum 1 upper shrift \nMinimum 1 lower shrift \nMinimum 1 symbol");
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine("Something went wrong,Please try again! ");
}
Console.WriteLine();
Thread.Sleep(5000);
Console.Clear();

Main(args);
}

public static void Password(string s)
{
bool NumCounter = false, UpperCounter = false, LowerCounter = false, SymbolCounter = false;
for (int i = 0; i < s.Length; i++)
{
if (char.IsDigit(s[i]))
{
NumCounter = true;
}
if (char.IsUpper(s[i]))
{
UpperCounter = true;
}
if (char.IsLower(s[i]))
{
LowerCounter = true;
}
if (!char.IsDigit(s[i]) && !char.IsLetter(s[i]))
{
SymbolCounter = true;
}
}

if (s.Length >= 8 && NumCounter && UpperCounter && LowerCounter && SymbolCounter)
{
Console.WriteLine("Your password has been successfully saved, Congratulations! ");
}
else
{
throw new InvalidPasswordException("Sorry your password does not match the requirements");
}
}
}
}