Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Weaponsmith
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> weaponsName = Console.ReadLine()
- .Split("|", StringSplitOptions.RemoveEmptyEntries)
- .ToList();
- StringBuilder weapon = new StringBuilder();
- while (true)
- {
- string[] command = Console.ReadLine().Split().ToArray();
- if (command[0] == "Done")
- { break; }
- switch (command[0])
- {
- case "Move":
- if (command[1] == "Left")
- {
- int index = int.Parse(command[2]); if (index <= 0 || index > weaponsName.Count - 1)
- { continue; }
- int a = -1;
- GetMovedList(weaponsName, index,a);
- }
- if (command[1] == "Right")
- {
- int index = int.Parse(command[2]); if (index < 0 || index >= weaponsName.Count - 1)
- { continue; }
- int a = +1;
- GetMovedList(weaponsName, index, a);
- }
- break;
- case "Check":
- if (command[1] == "Even")
- { int b = 0;
- GetPrintChecked(weaponsName, b);
- }
- if (command[1] == "Odd")
- {
- int b = 1;
- GetPrintChecked(weaponsName, b);
- }
- break;
- }
- }
- foreach (var letters in weaponsName)
- {
- weapon.Append(letters);
- }
- Console.WriteLine($"You crafted {weapon}!");
- }
- static void GetPrintChecked(List<string> list, int b)
- {
- for (int i = 0; i < list.Count; i++)
- {
- if (i % 2 == b)
- Console.Write(list[i] +" ");
- }
- Console.WriteLine();
- }
- static List<string> GetMovedList(List<string> weaponsName, int index, int a)
- {
- if (index <= weaponsName.Count - 1 && index >= 0)
- { string forMove = weaponsName[index];
- string second = weaponsName[index +a];
- weaponsName.RemoveAt(index);
- weaponsName.Insert(index, second);
- weaponsName.RemoveAt(index +a);
- weaponsName.Insert(index +a, forMove);
- }
- return weaponsName;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement