Advertisement
silvana1303

easter gifts

Jun 16th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Threading;
  6.  
  7. namespace ConsoleApp1
  8. {
  9.     class Exam
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<string> gifts = Console.ReadLine().Split().ToList();
  14.  
  15.             string[] command = Console.ReadLine().Split().ToArray();
  16.  
  17.             while (command[0] != "No")
  18.             {
  19.                 if (command[0] == "OutOfStock")
  20.                 {
  21.                     for (int i = 0; i < gifts.Count; i++)
  22.                     {
  23.                         if (gifts[i].Equals(command[1]))
  24.                         {
  25.                             gifts[i] = "None";
  26.                         }
  27.                     }
  28.                 }
  29.                 if (command[0] == "Required")
  30.                 {
  31.                     int index = int.Parse(command[2]);
  32.  
  33.                     if (index >= 0 && index < gifts.Count)
  34.                     {
  35.                         gifts[index] = command[1];
  36.                     }
  37.                 }
  38.                 if (command[0] == "JustInCase")
  39.                 {
  40.                     gifts[gifts.Count - 1] = command[1];
  41.                 }
  42.  
  43.                 command = Console.ReadLine().Split().ToArray();
  44.             }
  45.  
  46.             gifts.RemoveAll(x => x == "None");
  47.  
  48.             Console.WriteLine(string.Join(" ", gifts));
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement