Guest User

Untitled

a guest
Dec 18th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7.  
  8. namespace Login
  9. {
  10. class Program
  11. {
  12.  
  13. static void Main(string[] args)
  14. {
  15. Initialization();
  16. }
  17.  
  18. public static void Initialization()
  19. {
  20. int x = 0;
  21. int choice = 0;
  22.  
  23. while (x < 2)
  24. {
  25. Console.Clear();
  26.  
  27. Console.Write("Username: ");
  28. string username = Console.ReadLine();
  29.  
  30. Console.Write("nPassword: ");
  31. string password = Console.ReadLine();
  32.  
  33. Console.WriteLine();
  34.  
  35. string option1 = "Login";
  36. string option2 = "Exit";
  37.  
  38. Console.WriteLine(option1 + "n" + option2);
  39.  
  40. while (x < 2)
  41. {
  42. ConsoleKeyInfo info = Console.ReadKey();
  43. if (info.Key == ConsoleKey.UpArrow)
  44. {
  45. Console.Clear();
  46. Console.ResetColor();
  47.  
  48. Console.WriteLine("Username: {0}", username);
  49. Console.WriteLine("nPassword: {0}n", password);
  50.  
  51. Console.ForegroundColor = ConsoleColor.Red;
  52. Console.WriteLine(option1);
  53.  
  54. Console.ResetColor();
  55. Console.WriteLine(option2);
  56.  
  57. choice = 1;
  58. }
  59. else if (info.Key == ConsoleKey.DownArrow)
  60. {
  61. Console.Clear();
  62. Console.ResetColor();
  63.  
  64. Console.WriteLine("Username: {0}", username);
  65. Console.WriteLine("nPassword: {0}n", password);
  66.  
  67. Console.ResetColor();
  68. Console.WriteLine(option1);
  69.  
  70. Console.ForegroundColor = ConsoleColor.Red;
  71. Console.WriteLine(option2);
  72. choice = 2;
  73.  
  74. }
  75.  
  76. if (info.Key == ConsoleKey.Enter && choice == 1)
  77. {
  78. if (Login(username, password) == true)
  79. {
  80. Console.WriteLine("Welcome");
  81. x = 2;
  82. }
  83. else
  84. {
  85. Console.WriteLine("Wrong password!");
  86. Console.ReadLine();
  87. break;
  88. }
  89.  
  90. }
  91. else if (info.Key == ConsoleKey.Enter && choice == 2)
  92. {
  93. Shutdown();
  94. }
  95. }
  96. }
  97.  
  98.  
  99. }
  100. public static void Shutdown()
  101. {
  102. Console.ResetColor();
  103. System.Environment.Exit(0);
  104. }
  105. public static bool Login(string username, string password)
  106. {
  107. if(username == "asd" && password == "asd")
  108. {
  109. Console.WriteLine("Welcome");
  110. return true;
  111. }
  112. else
  113. {
  114. return false;
  115. }
  116. }
  117. }
  118. }
Add Comment
Please, Sign In to add comment