Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Inventory
- {
- class Program
- {
- static void Main(string[] args)
- {
- var collectedItems = Console.ReadLine().Split(", ").ToList();
- string commands;
- while ((commands = Console.ReadLine()) != "Craft!")
- {
- var tokens = commands.Split(" - ");
- string command = tokens[0], item = tokens[1];
- if (command == "Collect")
- {
- if (!collectedItems.Contains(item))
- {
- collectedItems.Add(item);
- }
- }
- else if (command == "Drop")
- {
- if (collectedItems.Contains(item))
- {
- collectedItems.Remove(item);
- }
- }
- else if (command == "Combine Items")
- {
- var oldNewItems = item.Split(':');
- string oldItem = oldNewItems[0], newItem = oldNewItems[1];
- if (collectedItems.Contains(oldItem))
- {
- collectedItems.Insert(collectedItems.IndexOf(oldItem) + 1, newItem);
- }
- }
- else
- {
- if (collectedItems.Contains(item))
- {
- collectedItems.Remove(item);
- collectedItems.Add(item);
- }
- }
- }
- Console.WriteLine(String.Join(", ", collectedItems));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement