Example #1
0
        public void SetupGame(string path)
        {
            try
            {
                string       filePath    = path;
                IInputReader inputReader = FileInputReader.Instance;
                string[]     input       = inputReader.ReadInput(filePath);

                GameDriver driver = new GameDriver(logger);
                driver.ValidateInputs(input);
                driver.Initialize(input);
                driver.StartGame();
            }

            catch (InvalidFilePathException)
            {
                logger.Log("InValid file path.");
            }
            catch (InvalidInputException ex)
            {
                logger.Log($"Exception occured : {ex.message}");
            }
            catch (Exception ex)
            {
                logger.Log($"Error occured , please reach out to support team. Message : { ex.Message}");
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            string filePath = string.Empty;

            ILogger      logger      = ConsoleLogger.Intance;
            IInputReader inputReader = FileInputReader.Intance;

            if (args.Length > 0)
            {
                try
                {
                    filePath = args[0];
                    string[]   input  = inputReader.ReadInput(filePath);
                    GameDriver driver = new GameDriver(logger);
                    driver.Start(input);
                }
                catch (InvalidFilePathException)
                {
                    logger.Log("InValid file path.");
                }
                catch (InvalidInputException ex)
                {
                    logger.Log($"Exception occured : {ex.message}");
                }
                catch (Exception ex)
                {
                    logger.Log($"Error occured , please reach out to support team. Message : { ex.Message}");
                }
            }
            else
            {
                logger.Log("Please provide file path in arguments.");
            }

            logger.Log("Press any key to Exit!");
            Console.ReadKey();
        }