Advertisement
abushik

SoftUni Parking

Mar 10th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace deletee
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. Dictionary<string, string> register = new Dictionary<string, string>();
  12.  
  13. int n = int.Parse(Console.ReadLine());
  14.  
  15. for (int i = 0; i < n; i++)
  16. {
  17. string[] line = Console.ReadLine().Split().ToArray();
  18. string reg = line[0];
  19. string userName = line[1];
  20. //string licenseNum = line[2];
  21.  
  22. if (reg == "register")
  23. {
  24. string licenseNum = line[2];
  25. if (!register.ContainsKey(userName))
  26. {
  27. register.Add(userName, licenseNum);
  28. Console.WriteLine($"{userName} registered {licenseNum} successfully");
  29. }
  30. else
  31. {
  32. Console.WriteLine($"ERROR: already registered with plate number {licenseNum}");
  33. }
  34. }
  35. else if (reg == "unregister")
  36. {
  37. if (!register.ContainsKey(userName))
  38. {
  39.  
  40. Console.WriteLine($"ERROR: user {userName} not found");
  41. }
  42. else
  43. {
  44. register.Remove(userName);
  45. Console.WriteLine($"{userName} unregistered successfully");
  46. }
  47. }
  48. }
  49. foreach (var item in register)
  50. {
  51. Console.WriteLine($"{item.Key} => {item.Value}");
  52. }
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement