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