E
E
embiid2020-12-24 19:27:43
C++ / C#
embiid, 2020-12-24 19:27:43

How to draw letters with characters by an implemented class?

Everyone had such tasks when they started to learn programming - draw and display a letter in the console, which is built from characters. And here's how to make it so that there is a field class that draws a field. And then draw a letter in this field. For example, there is a class Field. And there are, for example, methods to draw_lower_border, draw_left_border, and so on. What are the ways to implement this?

And for example, if the user enters what letter he wants to receive, then what is the best way to make it an event? and that you need to do as many events as there are letters in the alphabet? o_O

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-12-24
@firedragon

There was no such nonsense :)
well, create a switch for each character or for each pair
And pair it with a variable with a matrix

switch (char){

case "a":
case "A":
  ShowChar(char, charA); 
}
string charA = @"{0}{0}{0}
{0}{1}{0}
"; // лень писать, в общем 
void ShowChar(char char, string charMatrix){
   Console.WriteLine(string.Format(charMatrix), " ",  char);
}

Type of working code
using System;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            Run("A");
        }
        static void ShowChar(string str, string charMatrix)
        {
            Console.WriteLine(string.Format(charMatrix, " ", str));
        }
        const string charA = @"
{0}{1}{0}
{1}{0}{1}
{1}{1}{1}
{1}{0}{1}
                                "; // лень писать, в общем 
        static void Run(string s)
        {
            switch (s)
            {

                case "a":
                case "A":
                    ShowChar(s, charA);
                    break;
            }


        }
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question