TheBulgarianWolf

SoftUni Parking

Mar 3rd, 2021
630
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace SoftUni_Parking
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Console.WriteLine("Enter the number of lines you are about to enter: ");
  11.             int lines = int.Parse(Console.ReadLine());
  12.             Dictionary<string, string> parkingDictionary = new Dictionary<string, string>();
  13.             for(int i = 0; i < lines; i++)
  14.             {
  15.                 string[] input = Console.ReadLine().Split();
  16.                 string command = input[0];
  17.                 string username = input[1];
  18.                 if(command == "register")
  19.                 {
  20.                     string licensePlateNumber = input[2];
  21.                     if (parkingDictionary.ContainsKey(username))
  22.                     {
  23.                         Console.WriteLine("ERROR: already registered with plate number " + parkingDictionary[username]);
  24.                     }
  25.                     else
  26.                     {
  27.                         parkingDictionary.Add(username, licensePlateNumber);
  28.                         Console.WriteLine($"{username} registered {licensePlateNumber} successfully.");
  29.                     }
  30.                 }
  31.                 else
  32.                 {
  33.                     if (parkingDictionary.ContainsKey(username))
  34.                     {
  35.                         parkingDictionary.Remove(username);
  36.                         Console.WriteLine($"{username} unregistered successfully.");
  37.                     }
  38.                     else
  39.                     {
  40.                         Console.WriteLine($"ERROR: user {username} not found.");
  41.                     }
  42.                 }
  43.  
  44.                 foreach (var item in parkingDictionary)
  45.                 {
  46.                     Console.WriteLine(item.Key + " => " + item.Value);
  47.                 }
  48.             }
  49.         }
  50.     }
  51. }
  52.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×