Advertisement
silvana1303

softuni parking

Jul 8th, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 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 Microsoft.CSharp;
  7.  
  8.  
  9. namespace Order_By_Age
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             int times = int.Parse(Console.ReadLine());
  16.  
  17.             Dictionary<string, string> list = new Dictionary<string, string>();
  18.  
  19.             for (int i = 0; i < times; i++)
  20.             {
  21.                 string[] command = Console.ReadLine().Split().ToArray();
  22.  
  23.                 if (command[0] == "register")
  24.                 {
  25.                     if (list.ContainsKey(command[1]))
  26.                     {
  27.                         Console.WriteLine($"ERROR: already registered with plate number {command[2]}");
  28.                     }
  29.                     else
  30.                     {
  31.                         list.Add(command[1], command[2]);
  32.                         Console.WriteLine($"{command[1]} registered {command[2]} successfully");
  33.                     }
  34.                 }
  35.                 if (command[0] == "unregister")
  36.                 {
  37.                     if (list.ContainsKey(command[1]))
  38.                     {
  39.                         list.Remove(command[1]);
  40.                         Console.WriteLine($"{command[1]} unregistered successfully");
  41.                     }
  42.                     else
  43.                     {
  44.                         Console.WriteLine($"ERROR: user {command[1]} not found");
  45.                     }
  46.                 }
  47.             }
  48.  
  49.             foreach (var item in list)
  50.             {
  51.                 Console.WriteLine($"{item.Key} => {item.Value}");
  52.             }
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement