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