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