Advertisement
silvana1303

inventory

Jun 13th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.93 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5.  
  6. namespace ConsoleApp1
  7. {
  8.     class Exam
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             List<string> list = Console.ReadLine().Split(", ").ToList();
  13.  
  14.             List<string> command = Console.ReadLine().Split(" - ").ToList();
  15.  
  16.             while (command[0] != "Craft!")
  17.             {
  18.                 string commandName = command[0];
  19.                 string value = command[1];
  20.                 if (commandName == "Collect")
  21.                 {
  22.                     if (!(list.Contains(value)))
  23.                     {
  24.                         list.Add(value);
  25.                     }
  26.                 }
  27.                 else if (commandName == "Drop")
  28.                 {
  29.                     if (list.Contains(value))
  30.                     {
  31.                         list.Remove(value);
  32.                     }
  33.                 }
  34.                 else if (commandName == "Renew")
  35.                 {
  36.                     if (list.Contains(value))
  37.                     {
  38.                         string temp = command[1];
  39.                         list.Remove(value);
  40.                         list.Add(temp);
  41.                     }
  42.                 }
  43.                 else if (commandName == "Combine Items")
  44.                 {
  45.                     List<string> combine = value.Split(':').ToList();
  46.                     string oldItem = combine[0];
  47.                     string newItem = combine[1];
  48.                     if (list.Contains(oldItem))
  49.                     {
  50.                         int index = list.IndexOf(oldItem);
  51.                         int newIndex = index + 1;
  52.                         list.Insert(newIndex, newItem);
  53.                     }
  54.                 }
  55.  
  56.                 command = Console.ReadLine().Split(" - ").ToList();
  57.             }
  58.  
  59.             Console.WriteLine(string.Join(", ", list));
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement