simonradev

SottUniParty

May 25th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. namespace SoftUniParty
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.  
  6.     public class Startup
  7.     {
  8.         private static SortedSet<string> guestList;
  9.  
  10.         public static void Main()
  11.         {
  12.             guestList = new SortedSet<string>();
  13.  
  14.             ManageTheGuestList(item => guestList.Add(item), "PARTY");
  15.             ManageTheGuestList(item => guestList.Remove(item), "END");
  16.  
  17.             Console.WriteLine(guestList.Count);
  18.             Console.WriteLine(string.Join($"{Environment.NewLine}", guestList));
  19.         }
  20.  
  21.         public static void ManageTheGuestList(Action<string> executeActionOnSortedSet, string endWord)
  22.         {
  23.             string inputLine = Console.ReadLine();
  24.             while (inputLine != endWord)
  25.             {
  26.                 executeActionOnSortedSet(inputLine);
  27.  
  28.                 inputLine = Console.ReadLine();
  29.             }
  30.         }
  31.     }
  32. }
Add Comment
Please, Sign In to add comment