Example #1
0
        static void Main(string[] args)
        {
            DisplayIntro();

            var message = Input.ReadLine("Your message, please");
            var pattern = new LovePattern();

            var source = new SourceCharacters(pattern.LineLength, message);

            using var destination = Console.OpenStandardOutput();

            pattern.Write(source, destination);
        }
Example #2
0
        internal void Write(SourceCharacters source, Stream destination)
        {
            using var writer = new StreamWriter(destination);

            WritePadding(writer);

            var lineLength = 0;

            foreach (var segmentLength in _segmentLengths)
            {
                foreach (var character in source.GetCharacters(segmentLength))
                {
                    writer.Write(character);
                }
                lineLength += segmentLength;
                if (lineLength >= LineLength)
                {
                    writer.WriteLine();
                    lineLength = 0;
                }
            }

            WritePadding(writer);
        }