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_MidExam
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> journal = Console.ReadLine()
- .Split(", ")
- .ToList();
- string command = Console.ReadLine();
- while (command != "Craft!")
- {
- string[] newCommand = command.Split(" - ");
- //string instruction = newCommand[0];
- if (newCommand[0] == "Collect")
- {
- string item = newCommand[1];
- if (journal.Contains(item))
- {
- continue;
- }
- else
- {
- journal.Add(item);
- }
- }
- else if (newCommand[0] == "Drop")
- {
- string item = newCommand[1];
- if (journal.Contains(item))
- {
- journal.Remove(item);
- }
- }
- else if (newCommand[0] == "Combine Items")
- {
- string items = newCommand[1];
- string[] newItems = items.Split(":");
- string itemOne = newItems[0];
- string itemTwo = newItems[1];
- if (journal.Contains(itemOne))
- {
- int indexOldItem = journal.IndexOf(itemOne) + 1;
- journal.Insert(indexOldItem, itemTwo);
- }
- }
- else if (newCommand[0] == "Renew")
- {
- string item = newCommand[1];
- if (journal.Contains(item))
- {
- journal.Remove(item);
- journal.Add(item);
- }
- }
- command = Console.ReadLine();
- }
- if (command == "Craft!")
- {
- Console.WriteLine(string.Join(", ", journal));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement