fork download
  1. //Напишите программу, которая показвает менью выбора (Зарегистрироваться / Войти), при выборе регистрации
  2. //от пользователя требуется ввести имя, фамилию и возраст (логин должен сгенерировать с этих данных). А
  3. //пароль будет сгенерирован Рандомно (при этом может состоять из любых символов (буквы, числа, знаки)).
  4. //По окончанию регистрации пользователь возвращается на главное менью, где он может зарегистрировать еще
  5. //один аккаун или же сделать вход в систему. Все аккаунты храните в массиве классов аккаутн.
  6.  
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10.  
  11. namespace MyClass
  12.  
  13. {
  14. class User {
  15.  
  16. public string Name {
  17. get {return name;}
  18. set {this.name = value;}
  19. }
  20. public string SurName {
  21. get {return surname;}
  22. set {this.surname = value;}
  23. }
  24. public int Age {
  25. get {return age;}
  26. set {this.age = value;}
  27. }
  28.  
  29.  
  30. private string name;
  31. private string surname;
  32. private int age;
  33. }
  34. public class Program
  35. {
  36. public static void Main(string[] args)
  37. {
  38. User user = new User();
  39. List<User> users = new List<User>();
  40.  
  41. Console.WriteLine("1.Sign in");
  42. Console.WriteLine("2.Registration");
  43.  
  44. int ch = Convert.ToInt32(Console.ReadLine()); ;
  45. switch (ch) {
  46.  
  47. case 1:
  48.  
  49. break;
  50. case 2:
  51. Console.Write("Enter Name: ");
  52. user.Name = Console.ReadLine();
  53. Console.Write("\nEnter Surname: ");
  54. user.SurName = Console.ReadLine();
  55. Console.Write("\nEnter Name: ");
  56. user.Age = Convert.ToInt32(Console.ReadLine());
  57.  
  58. Console.WriteLine("You have succesfully registered!!");
  59. Console.Write("Your login is: ");
  60. Console.Write (NickGenerator(user.SurName));
  61. Console.Write("\nYour password is: ");
  62. Console.Write(CreatePassword());
  63. break;
  64.  
  65. default:
  66. break;
  67. }
  68.  
  69. }
  70.  
  71. public static string NickGenerator(string surname) {
  72. string nick;
  73. nick = surname.Substring(0,4) + "_" + CreatePassword(4);
  74. return nick;
  75. }
  76. public static string CreatePassword(int length) {
  77. const string val = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@-_";
  78. StringBuilder res = new StringBuilder();
  79. Random rnd = new Random();
  80. while (0 < length--) {
  81. res.Append(val[rnd.Next(val.Length)]);
  82. }
  83. return res.ToString();
  84.  
  85. }
  86. public static string CreatePassword() {
  87. int length = 8;
  88. const string val = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@-_";
  89. StringBuilder res = new StringBuilder();
  90. Random rnd = new Random();
  91. while (0 < length--) {
  92. res.Append(val[rnd.Next(val.Length)]);
  93. }
  94. return res.ToString();
  95.  
  96. }
  97.  
  98. }
  99. }
  100.  
Success #stdin #stdout 0.02s 16104KB
stdin
Standard input is empty
stdout
1.Sign in
2.Registration