Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Inventory
- {
- class Inventory
- {
- static void Main()
- {
- List<string> words = Console.ReadLine()
- .Split(", ")
- .ToList();
- string input = Console.ReadLine();
- while (input != "Craft!")
- {
- string[] splitedInput = input.Split(" - ");
- string command = splitedInput[0];
- if (command == "Collect")
- {
- string item = splitedInput[1];
- if (!words.Contains(item))
- {
- words.Add(item);
- }
- }
- else if (command == "Drop")
- {
- string item = splitedInput[1];
- if (words.Contains(item))
- {
- words.Remove(item);
- }
- }
- else if (command == "Combine Items")
- {
- string[] splitedInput1 = splitedInput[1].Split(':');
- string oldItem = splitedInput1[0];
- string newItem = splitedInput1[1];
- if (words.Contains(oldItem))
- {
- int index = words.IndexOf(oldItem);
- words.Insert(index + 1, newItem);
- }
- }
- else if (command == "Renew")
- {
- string item = splitedInput[1];
- if (words.Contains(item))
- {
- words.Remove(item);
- words.Add(item);
- }
- }
- input = Console.ReadLine();
- }
- Console.WriteLine(string.Join(", ", words));
- }
- }
- }
Add Comment
Please, Sign In to add comment