Advertisement
Guest User

Untitled

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