Exemplo n.º 1
0
        public object GenerateValue(Type exceptedType)
        {
            if (IsEnumerableChecker.Check(exceptedType))
            {
                return(EnumerableGenerator.GenerateEnumerable(exceptedType));
            }

            else if (IsArrayChecker.Check(exceptedType))
            {
                return(ArrayGenerator.GenerateArray(exceptedType));
            }

            else if (IsValueTypeChecker.Check(exceptedType))
            {
                return(ValueTypeActivator.ActivateInstance(exceptedType));
            }

            throw new AutoException(exceptedType);

            // TODO
            // IF REFERENCE_TYPE
            //     RETURN NEW REFERENCE_TYPE
        }
Exemplo n.º 2
0
        public void Run()
        {
            levelNumbers = arrayGenerator.GenerateArray(gameSettings.DoorsAmount);

            io.WriteOutput(phraseProvider.GetPhrase("WelcomeStart"));
            io.WriteOutput($"{gameSettings.ExitCode}");
            io.WriteOutput(phraseProvider.GetPhrase("WelcomeEnd"));

            while (true)
            {
                io.WriteOutput(phraseProvider.GetPhrase("Level"));
                io.WriteOutput($"{currentLevel}");
                io.WriteOutput(phraseProvider.GetPhrase("TheDoorsAre"));
                io.printArray(levelNumbers);

                do
                {
                    io.WriteOutput(phraseProvider.GetPhrase("Select"));

                    InputCheck();

                    if (selectedNum == gameSettings.ExitCode)
                    {
                        break;
                    }
                } while (!operationWithData.Contains(levelNumbers, selectedNum));

                if (selectedNum == gameSettings.ExitCode)
                {
                    io.WriteOutput(phraseProvider.GetPhrase("Thanks"));
                    break;
                }
                else if (selectedNum == gameSettings.ExitDoorNumber)
                {
                    if (currentLevel > 1)
                    {
                        operationWithData.Divide(levelNumbers, history.Pop());
                        io.WriteOutput(phraseProvider.GetPhrase("YouSelected"));
                        io.WriteOutput($"{selectedNum}");
                        io.WriteOutput(phraseProvider.GetPhrase("Previous"));
                        currentLevel--;
                    }
                    else if (currentLevel == 1)
                    {
                        io.WriteOutput(phraseProvider.GetPhrase("AlreadyFirst"));
                    }
                }
                else
                {
                    if (currentLevel < gameSettings.MaxLevel)
                    {
                        operationWithData.Multiply(levelNumbers, selectedNum);
                        history.Push(selectedNum);
                        io.WriteOutput(phraseProvider.GetPhrase("YouSelected"));
                        io.WriteOutput($"{selectedNum}");
                        io.WriteOutput(phraseProvider.GetPhrase("Next"));
                        currentLevel++;
                    }
                    else
                    {
                        io.WriteOutput(phraseProvider.GetPhrase("MaxLevelReached"));
                    }
                }
            }
            io.ReadKey();
        }