Advertisement
_CodeBehind

class StartUp

Jul 27th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class StartUp
  6. {
  7.     private static ListyIterator<string> data;
  8.  
  9.     public static void Main()
  10.     {
  11.         string command;
  12.         var createCommand = Console.ReadLine()
  13.             .Split(new []{' '},StringSplitOptions.RemoveEmptyEntries);
  14.  
  15.         data = new ListyIterator<string>(createCommand
  16.             .Skip(1)
  17.             .ToArray());
  18.  
  19.         var commands = new Dictionary<string, Action>
  20.         {
  21.             {"HasNext", () => Console.WriteLine(data.HasNext())},
  22.             {"Move", () => Console.WriteLine(data.Move())},
  23.             {"Print", () => Console.WriteLine(data.Print())},
  24.             {"PrintAll", () => Console.WriteLine(data.PrintAll()) }
  25.         };
  26.  
  27.         while ((command = Console.ReadLine()) != "END")
  28.         {
  29.             var commandName = command.Split().ToArray().FirstOrDefault();
  30.             try
  31.             {
  32.                 commands[commandName].Invoke();
  33.             }
  34.             catch (Exception e)
  35.             {
  36.                 Console.WriteLine(e.Message);
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement