Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _03QuestsJournal
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> journal = Console.ReadLine().Split(", ").ToList();
- while (true)
- {
- string command = Console.ReadLine();
- if (command=="Retire!")
- {
- break;
- }
- string[] tokens = command.Split(new string[] { " - ", ":"}, StringSplitOptions.RemoveEmptyEntries);
- string action = tokens[0];
- if (action == "Start")
- {
- string quest = tokens[1];
- if (journal.Contains(quest))
- {
- continue;
- }
- journal.Add(quest);
- }
- else if (action=="Complete")
- {
- string quest = tokens[1];
- if (journal.Contains(quest))
- {
- journal.Remove(quest);
- }
- }
- else if (action == "Side Quest")
- {
- string quest = tokens[1];
- string sideQuest = tokens[2];
- if (journal.Contains(quest))
- {
- int index = journal.IndexOf(quest);
- if (journal.Contains(sideQuest)==false)
- {
- journal.Insert(index + 1, sideQuest);
- }
- }
- }
- else if (action == "Renew")
- {
- string quest = tokens[1];
- if (journal.Contains(quest))
- {
- int index = journal.IndexOf(quest);
- journal.Add(quest);
- journal.RemoveAt(index);
- }
- }
- }
- Console.WriteLine(string.Join(", ",journal));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment