Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace SoftUniParking
- {
- class Program
- {
- static void Main(string[] args)
- {
- int numbersOfCommands = int.Parse(Console.ReadLine());
- var license = new Dictionary<string, string>();
- for (int i = 0; i < numbersOfCommands; i++)
- {
- string[] tokens = Console.ReadLine().Split(" ").ToArray();
- string command = tokens[0];
- string name = tokens[1];
- switch (command)
- {
- case "register":
- string licensePlateNumber = tokens[2];
- if (license.ContainsKey(name))
- {
- Console.WriteLine($"ERROR: already registered with plate number {licensePlateNumber}");
- }
- else
- {
- Console.WriteLine($"{name} registered {licensePlateNumber} successfully");
- license.Add(name, licensePlateNumber);
- }
- break;
- case "unregister":
- if (license.ContainsKey(name))
- {
- license.Remove(name);
- Console.WriteLine($"{name} unregistered successfully");
- }
- break;
- }
- }
- foreach (var kvp in license)
- {
- Console.WriteLine($"{kvp.Key} => {kvp.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement