Advertisement
Grimmjow1

Quests Journal

Jun 25th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace QuestJournal
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.  
  12.             List<string> jurnal = Console.ReadLine().Split(", ").ToList();
  13.             while (true)
  14.             {
  15.                 string data = Console.ReadLine();
  16.                 if (data == "Retire!")
  17.                 {
  18.                     break;
  19.                 }
  20.                 string[] commands = data.Split(" - ");
  21.                 string command = commands[0];
  22.                 if (command == "Start")
  23.                 {
  24.                     string quest = commands[1];
  25.                     if (jurnal.Contains(quest) == false)
  26.                     {
  27.                         jurnal.Add(quest);
  28.                     }
  29.                     else
  30.                     {
  31.                         continue;
  32.                     }
  33.  
  34.                 }
  35.                 else if (command == "Complete")
  36.                 {
  37.                     string quest = commands[1];
  38.                     if (jurnal.Contains(quest))
  39.                     {
  40.                         jurnal.Remove(quest);
  41.                     }
  42.                     else
  43.                     {
  44.                         continue;
  45.                     }
  46.                 }
  47.                 else if (command == "Side Quest")
  48.                 {
  49.                     string[] questSideQuest = commands[1].Split(':');
  50.                     string quest = questSideQuest[0];
  51.                     string sideQuest = questSideQuest[1];
  52.                     if (jurnal.Contains(quest) && jurnal.Contains(sideQuest) == false)
  53.                     {
  54.                         int index = jurnal.IndexOf(quest);
  55.                         if (index+1>jurnal.Count)
  56.                         {
  57.                             jurnal.Add(sideQuest);
  58.                         }
  59.                         else
  60.                         {
  61.                             jurnal.Insert(index + 1, sideQuest);
  62.                         }
  63.                        
  64.                     }
  65.                 }
  66.                 else if (command=="Renew")
  67.                 {
  68.                     string quest = commands[1];
  69.                     if (jurnal.Contains(quest))
  70.                     {
  71.                         int index = jurnal.IndexOf(quest);
  72.                         jurnal.RemoveAt(index);
  73.                         jurnal.Add(quest);
  74.                     }
  75.                 }
  76.             }
  77.             Console.WriteLine(string.Join(", ",jurnal));
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement