Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- namespace CSharp_Shell
- {
- public static class Program
- {
- public static void Main()
- {
- var parking = new Dictionary<string, string>();
- var n = int.Parse(Console.ReadLine());
- for(int i=0;i<n;i++)
- {
- var input = Console.ReadLine().Split();
- var command = input[0];
- if(command == "register")
- {
- var username = input[1];
- var licensePlateNumber= input[2];
- if(!parking.ContainsKey(username))
- {
- parking[username] = string.Empty;
- }
- if(parking[username] == string.Empty)
- {
- parking[username] = licensePlateNumber;
- Console.WriteLine($"{username} registered {licensePlateNumber} successfully");
- }
- else
- {
- Console.WriteLine($"ERROR: already registered with plate number {licensePlateNumber}");
- }
- }
- else if(command=="unregister")
- {
- var username = input[1];
- if(!parking.ContainsKey(username))
- {
- Console.WriteLine($"ERROR: user {username} not found");
- }
- else
- {
- Console.WriteLine($"{username} unregistered successfully");
- parking.Remove(username);
- }
- }
- }
- foreach(var kvp in parking)
- {
- Console.WriteLine($"{kvp.Key} => {kvp.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement