Advertisement
dinko_dt

Untitled

Feb 29th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5.  
  6. namespace Inventory
  7. {
  8. class Inventory
  9. {
  10. static void Main()
  11. {
  12. List<string> words = Console.ReadLine()
  13. .Split(", ")
  14. .ToList();
  15. string input = Console.ReadLine();
  16.  
  17. while (input != "Craft!")
  18. {
  19. string[] splitedInput = input.Split(" - ");
  20. string command = splitedInput[0];
  21.  
  22. if (command == "Collect")
  23. {
  24. string item = splitedInput[1];
  25. if (!words.Contains(item))
  26. {
  27. words.Add(item);
  28. }
  29.  
  30.  
  31. }
  32. else if (command == "Drop")
  33. {
  34. string item = splitedInput[1];
  35. if (words.Contains(item))
  36. {
  37. words.Remove(item);
  38. }
  39. }
  40. else if (command == "Combine Items")
  41. {
  42. string[] splitedInput1 = splitedInput[1].Split(':');
  43. string oldItem = splitedInput1[0];
  44. string newItem = splitedInput1[1];
  45.  
  46. if (words.Contains(oldItem))
  47. {
  48. int index = words.IndexOf(oldItem);
  49. words.Insert(index + 1, newItem);
  50.  
  51. }
  52.  
  53. }
  54. else if (command == "Renew")
  55. {
  56. string item = splitedInput[1];
  57. if (words.Contains(item))
  58. {
  59. words.Remove(item);
  60. words.Add(item);
  61. }
  62.  
  63. }
  64. input = Console.ReadLine();
  65. }
  66.  
  67. Console.WriteLine(string.Join(", ", words));
  68. }
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement