Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PassLockBetter
- {
- class Program
- {
- static string UserName;
- static string Password;
- static List<string> accounts = new List<string>();
- static List<string> userNames = new List<string>();
- static int counter = 0;
- static void Main(string[] args)
- {
- Start();
- }
- static void Start()
- {
- Console.WriteLine("Type 'REGISTER' to register a new account or type 'LOGIN' to login to your existing account");
- string LOR = Console.ReadLine();
- if (LOR == "LOGIN")
- {
- Login();
- }
- if (LOR == "REGISTER")
- {
- Register();
- }
- }
- static void Register()
- {
- bool UsrNameConf = false;
- bool PssWrdConf = false;
- Console.WriteLine("Please enter a username (4 characters minimum length and 12 characters maximum length)");
- string UN = Console.ReadLine();
- if (4 <= UN.Length && 12 >= UN.Length)
- {
- if (userNames.Contains(UN))
- {
- Console.WriteLine("username already exists");
- Register();
- }
- else
- {
- UserName = UN;
- UsrNameConf = true;
- }
- }
- else
- {
- Console.WriteLine("not a valid username");
- Start();
- }
- while (UsrNameConf && !PssWrdConf)
- {
- Console.WriteLine("enter a password (4 characters minimum length and 18 characters maximum length)");
- string PW = Console.ReadLine();
- if (PW.Length >= 4 && PW.Length <= 18)
- {
- Password = PW;
- PssWrdConf = true;
- }
- else
- {
- Console.WriteLine("not a valid password");
- }
- }
- if (UsrNameConf && PssWrdConf)
- {
- userNames.Add(UserName);
- accounts.Add(UserName + Password);
- UserName = "";
- Password = "";
- Console.WriteLine("Account successfuly registered");
- Start();
- }
- }
- static void Login()
- {
- string PW;
- string UN;
- Console.WriteLine("Type in your username");
- UN = Console.ReadLine();
- Console.WriteLine("Type in your password");
- PW = Console.ReadLine();
- if (accounts.Contains(UN + PW))
- {
- Console.WriteLine("Welcome to your account " + UN);
- Start();
- }
- else
- {
- Console.WriteLine("Invalid password or username");
- counter += 1;
- if (counter == 3)
- {
- Console.WriteLine("You are locked out. Wait for 10 seconds to continue ");
- lockedWait();
- Login();
- }
- else
- {
- Login();
- }
- }
- }
- static void lockedWait()
- {
- System.Threading.Thread.Sleep(10000); //1000 = 1 SECOND
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement