Advertisement
Guest User

Untitled

a guest
Feb 7th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 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. using System.IO;
  7.  
  8. namespace NEA
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. Register();
  15. }
  16. static void Register()
  17. {
  18. string usernameToFile = getUsername();
  19. string passwordToFile = getPassword();
  20. writeAccountToFile(usernameToFile,passwordToFile);
  21.  
  22. //Local Function getUsername retrieves name, age and year group and forms the username
  23. string getUsername()
  24. {
  25. //Input name
  26. Console.Write("Enter name: ");
  27. string name = Console.ReadLine();
  28.  
  29. //Input age
  30. Console.Write("Enter age: ");
  31. string age = Console.ReadLine();
  32.  
  33. //Enter year group
  34. Console.Write("Enter year group: ");
  35. string yearGroup = Console.ReadLine();
  36.  
  37. //Does the name contain less than 3 characters?
  38. string usernamePrefix;
  39. if (name.Length > 3)
  40. {
  41. usernamePrefix = name.Substring(0, 3);
  42. }
  43. else
  44. {
  45. usernamePrefix = name;
  46. }
  47.  
  48. //Creating username
  49. string username = usernamePrefix + age;
  50.  
  51. //Is the username a duplicate? CANNOT CREATE UNTIL ABLE TO WRITE TO FILE FOR FORMATTING REASONS
  52. /*
  53. string[] lines = File.ReadAllLines(@"C:\Users\maxto\Desktop\accounts.txt");
  54.  
  55. foreach(string line in lines)
  56. {
  57. } */
  58.  
  59. return username;
  60. }
  61.  
  62. //Local Function getPassword retrieves the password from the user and checks that it is longer than 7 chars
  63. string getPassword()
  64. {
  65. //Input password
  66. Console.Write("\nEnter your new password: ");
  67. string password = Console.ReadLine();
  68.  
  69. //Does the password contain 8 or more characters?
  70. if(password.Length < 8)
  71. {
  72. Console.WriteLine("Password must be at least 8 characters");
  73. getPassword();
  74. }
  75. return password;
  76. }
  77.  
  78. //Local Function writeAccount will write the username and password to a file
  79. void writeAccountToFile(string username,string password)
  80. {
  81. Console.WriteLine("test");
  82. /*using (StreamWriter accountWriter = new StreamWriter(@"C:\Users\maxto\Desktop\accounts.txt"))
  83. {
  84. accountWriter.WriteLine();
  85. }*/
  86. }
  87.  
  88. }
  89. }
  90. public class DebugVars
  91. {
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement