Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace P03.Inventory
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- List<string> items = Console.ReadLine()
- .Split(", ", StringSplitOptions.RemoveEmptyEntries)
- .ToList();
- string command = Console.ReadLine();
- while (command != "Craft!")
- {
- string[] cmdArgs = command.Split(" - ");
- string action = cmdArgs[0];
- string item = cmdArgs[1];
- if (action == "Collect")
- {
- if (!items.Contains(item))
- {
- items.Add(item);
- }
- }
- else if (action == "Drop")
- {
- if (items.Contains(item))
- {
- items.Remove(item);
- }
- }
- else if (action == "Combine Items")
- {
- string[] itemsToCombine = item.Split(":");
- string olditem = cmdArgs[0];
- string newItem = cmdArgs[1];
- if (items.Contains(olditem))
- {
- items.Insert((items.IndexOf(olditem) + 1), newItem);
- }
- }
- else if(action == "Renew")
- {
- if(items.Contains(item))
- {
- items.Remove(item);
- items.Add(item);
- }
- }
- command = Console.ReadLine();
- }
- Console.WriteLine(String.Join(", ", items));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment