Пример #1
0
        public void FindPatternTestRandomDiamond()
        {
            var printer = new PatternPrinter();
            var pattern = printer.FindPattern("9");

            Assert.AreEqual(new PatternRandomDiamond().GetType(), pattern.GetType());
        }
Пример #2
0
        public void FindPatternTestIncreasePyramid()
        {
            var printer = new PatternPrinter();
            var pattern = printer.FindPattern("6");

            Assert.AreEqual(new PatternIncreasePyramid().GetType(), pattern.GetType());
        }
Пример #3
0
        public void FindPatternTestRightUpPyramid()
        {
            var printer = new PatternPrinter();
            var pattern = printer.FindPattern("7");

            Assert.AreEqual(new PatternRightUpPyramid().GetType(), pattern.GetType());
        }
Пример #4
0
        public void FindPatternTestHorn()
        {
            var printer = new PatternPrinter();
            var pattern = printer.FindPattern("5");

            Assert.AreEqual(new PatternHorn().GetType(), pattern.GetType());
        }
Пример #5
0
        static void Main(string[] args)
        {
            SequenceManagement sequence   = new SequenceManagement();
            PatternPrinter     printer    = new PatternPrinter();
            string             readString = String.Empty;
            int resultNum = 0;

            while (true)
            {
                readString = String.Empty;
                resultNum  = 0;

                printer.RequestInputTypeMessage();
                sequence.RequestTerminationCodeMessage();
                readString = Console.ReadLine();
                if (sequence.CheckTerminationCode(readString))
                {
                    sequence.PrintTerminationMessage();
                    return;
                }

                var pattern = printer.FindPattern(readString);
                if (pattern == null)
                {
                    printer.InvaildPatternTypeMessage();
                    continue;
                }

                pattern.RequestInputMessage();
                sequence.RequestTerminationCodeMessage();
                readString = Console.ReadLine();
                if (sequence.CheckTerminationCode(readString))
                {
                    sequence.PrintTerminationMessage();
                    return;
                }

                if (Int32.TryParse(readString, out resultNum) == false)
                {
                    pattern.InvalidInputRangeMessage();
                    continue;
                }

                if (pattern.IsOutOfRange(resultNum))
                {
                    pattern.InvalidInputRangeMessage();
                    continue;
                }

                Console.Clear();
                var asterisk = pattern.Print(resultNum);
                Console.WriteLine(asterisk);

                sequence.RequestTerminationCodeMessage();
                readString = Console.ReadLine();
                if (sequence.CheckTerminationCode(readString))
                {
                    sequence.PrintTerminationMessage();
                    return;
                }

                Console.Clear();
            }
        }