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