TheBulgarianWolf

House party

Nov 22nd, 2020
910
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace House_Party
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Console.Write("Enter the number of commands you are about to enter: ");
  11.             int numberOfCommands = int.Parse(Console.ReadLine());
  12.             List<string> guests = new List<string>();
  13.             for (int i = 0; i < numberOfCommands; i++)
  14.             {
  15.                 //Enter something like this: "Tom is going/not going to the party."
  16.                 string input = Console.ReadLine();
  17.                 string[] inputArr = input.Split();
  18.                 if (input.Contains("not going"))
  19.                 {
  20.                     if (guests.Contains(inputArr[0]))
  21.                     {
  22.                         guests.Remove(inputArr[0]);
  23.                     }
  24.                     else
  25.                     {
  26.                         continue;
  27.                     }
  28.                 }
  29.                 else if (input.Contains("going"))
  30.                 {
  31.                     if (guests.Contains(inputArr[0]))
  32.                     {
  33.                         Console.WriteLine(inputArr[0]  + " is already in the list!");
  34.                     }
  35.                     else
  36.                     {
  37.                         guests.Add(inputArr[0]);
  38.                     }
  39.                    
  40.                 }
  41.  
  42.             }
  43.  
  44.             foreach (string name in guests)
  45.             {
  46.                 Console.WriteLine(name);
  47.             }
  48.  
  49.         }
  50.     }
  51. }
  52.  
Add Comment
Please, Sign In to add comment