Advertisement
Katina_

HouseParty

Jun 21st, 2019
892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.61 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace houseParty
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int numberOfCommands = int.Parse(Console.ReadLine());
  12.             int count = 0;
  13.             string command = string.Empty;
  14.             string name = string.Empty;
  15.  
  16.             List<string> guests = new List<string>();
  17.  
  18.             while(count < numberOfCommands)
  19.             {
  20.                 command = Console.ReadLine();
  21.                 string[] part = command.Split();
  22.                 name = part[0];
  23.  
  24.                 if (part[1] == "is" && part[2] == "going!")
  25.                 {
  26.                     if (!guests.Contains(name))
  27.                     {
  28.                         guests.Add(name);
  29.                     }
  30.  
  31.                     else
  32.                     {
  33.                         Console.WriteLine($"{name} is already in the list!");
  34.                     }
  35.                 }
  36.  
  37.                 if (part[2] == "not")
  38.                 {
  39.                     if (guests.Contains(name))
  40.                     {
  41.                         guests.Remove(name);
  42.                        
  43.                     }
  44.                     else
  45.                     {
  46.                         Console.WriteLine($"{name} is not in the list!");
  47.                     }
  48.                 }
  49.                 count++;
  50.             }
  51.  
  52.             //Console.WriteLine(string.Join(Environment.NewLine,guests));
  53.  
  54.             foreach (string guest in guests)
  55.             {
  56.                 Console.WriteLine(guest);
  57.             }  
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement