Advertisement
Guest User

Untitled

a guest
Nov 21st, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9. class Program
  10. {
  11. static void login()
  12. {
  13. string username = "xrx"; //username
  14. Console.ForegroundColor = ConsoleColor.Yellow;
  15. Console.WriteLine("Username: ");
  16. Console.ForegroundColor = ConsoleColor.White;
  17. string userfield = Console.ReadLine();
  18. if (userfield == username)
  19. {
  20. password();
  21. }
  22. else
  23. {
  24. Console.ForegroundColor = ConsoleColor.Red;
  25. Console.WriteLine("Invalid Username!");
  26. Console.ForegroundColor = ConsoleColor.White;
  27. login();
  28. }
  29. }
  30. static void logged()
  31. {
  32. bool logged = true;
  33. Console.WriteLine("Welcome to xrx Interface!");
  34. Console.WriteLine("How i can help you today?");
  35. Console.WriteLine("Type ''help'' to see whats available");
  36. while (logged)
  37. {
  38. string[] cmds = new string[3] { "help", "logoff", "about" };
  39. string[] cmdresponse = new string[2] { "y", "n" };
  40. string cmdline = Console.ReadLine();
  41. if (cmdline == cmds[0])
  42. {
  43. Console.WriteLine("Available Commands: {0} {1} {2}", cmds);
  44. }
  45. else if (cmdline == cmds[1])
  46. {
  47. Console.WriteLine("Are you sure? (y or n)");
  48. cmdline = Console.ReadLine();
  49. if (cmdline == cmdresponse[0])
  50. {
  51. login();
  52. }
  53. }
  54. else if (cmdline == cmds[2])
  55. {
  56. Console.WriteLine("Created by xrx on 21/11/2016");
  57. }
  58. else
  59. {
  60. Console.ForegroundColor = ConsoleColor.Red;
  61. Console.WriteLine("Command Not Found!");
  62. Console.ForegroundColor = ConsoleColor.White;
  63. }
  64. }
  65. }
  66. static void password()
  67. {
  68. string password = "xrx1";
  69. Console.ForegroundColor = ConsoleColor.Yellow;
  70. Console.WriteLine("Password: ");
  71. Console.ForegroundColor = ConsoleColor.Black;
  72. string pwfield = Console.ReadLine();
  73. Console.ForegroundColor = ConsoleColor.White;
  74. if (pwfield == password)
  75. {
  76. Console.ForegroundColor = ConsoleColor.Green;
  77. Console.WriteLine("Access Granted!");
  78. Console.ForegroundColor = ConsoleColor.White;
  79. logged();
  80. }
  81. else
  82. {
  83. Console.ForegroundColor = ConsoleColor.Red;
  84. Console.WriteLine("Invalid Password!");
  85. Console.ForegroundColor = ConsoleColor.White;
  86. login();
  87. }
  88. }
  89. static void Main(string[] args)
  90. {
  91. Console.Title = "xrx interface v1.1";
  92. login();
  93. }
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement