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