Imitación De La Utilidad Banner Sysv De Unix En C#

Este programa imita la utilidad básica "banner" de Unix SysV. El programa recibe una cadena de texto del usuario y la muestra en caracteres ASCII grandes, similar al comando "banner" de los sistemas Unix. Este ejercicio se centra en comprender cómo gestionar el formato de texto en una ventana de terminal mediante la lógica básica de C# para convertir cada carácter en una representación ASCII grande.

Grupo

Matrices, estructuras y cadenas de C#

Objectivo

1. El programa solicitará al usuario que introduzca una cadena de texto.
2. Una vez que el usuario introduzca la información, el programa convertirá el texto en una representación grande y estilizada utilizando caracteres ASCII.
3. El texto grande se mostrará en pantalla, y cada carácter se representará mediante una secuencia de caracteres (como "###", "###", etc.).
4. Deberá crear un diccionario o método que convierta cada carácter en la representación ASCII grande correspondiente.
5. Asegúrese de que el programa gestione tanto mayúsculas como minúsculas, y los espacios entre palabras.

Escriba un programa en C# que imite la utilidad básica "banner" de Unix SysV, capaz de mostrar textos grandes.

Ejemplo de ejercicio en C#

 Copiar código C#
using System;
using System.Collections.Generic;

class BannerUtility
{
    // Dictionary to store ASCII representation for each character
    static Dictionary bannerChars = new Dictionary
    {
        { 'A', new string[] { "  A  ", " A A ", "AAAAA", "A   A", "A   A" } },
        { 'B', new string[] { "BBBB ", "B   B", "BBBB ", "B   B", "BBBB " } },
        { 'C', new string[] { " CCC ", "C    ", "C    ", "C    ", " CCC " } },
        { 'D', new string[] { "DDDD ", "D   D", "D   D", "D   D", "DDDD " } },
        { 'E', new string[] { "EEEEE", "E    ", "EEE  ", "E    ", "EEEEE" } },
        { 'F', new string[] { "FFFFF", "F    ", "FFF  ", "F    ", "F    " } },
        { 'G', new string[] { " GGG ", "G    ", "G  GG", "G   G", " GGG " } },
        { 'H', new string[] { "H   H", "H   H", "HHHHH", "H   H", "H   H" } },
        { 'I', new string[] { "IIIII", "  I  ", "  I  ", "  I  ", "IIIII" } },
        { 'J', new string[] { "JJJJJ", "    J", "    J", "J   J", "JJJJ " } },
        { 'K', new string[] { "K   K", "K  K ", "KK   ", "K  K ", "K   K" } },
        { 'L', new string[] { "L    ", "L    ", "L    ", "L    ", "LLLLL" } },
        { 'M', new string[] { "M   M", "MM MM", "M M M", "M   M", "M   M" } },
        { 'N', new string[] { "N   N", "NN  N", "N N N", "N  NN", "N   N" } },
        { 'O', new string[] { " OOO ", "O   O", "O   O", "O   O", " OOO " } },
        { 'P', new string[] { "PPPP ", "P   P", "PPPP ", "P    ", "P    " } },
        { 'Q', new string[] { " QQQ ", "Q   Q", "Q   Q", "Q  Q ", " QQ Q " } },
        { 'R', new string[] { "RRRR ", "R   R", "RRRR ", "R   R", "R   R" } },
        { 'S', new string[] { " SSS ", "S    ", " SSS ", "    S", " SSS " } },
        { 'T', new string[] { "TTTTT", "  T  ", "  T  ", "  T  ", "  T  " } },
        { 'U', new string[] { "U   U", "U   U", "U   U", "U   U", " UUU " } },
        { 'V', new string[] { "V   V", "V   V", "V   V", " V V ", "  V  " } },
        { 'W', new string[] { "W   W", "W   W", "W W W", "WW WW", "W   W" } },
        { 'X', new string[] { "X   X", " X X ", "  X  ", " X X ", "X   X" } },
        { 'Y', new string[] { "Y   Y", " Y Y ", "  Y  ", "  Y  ", "  Y  " } },
        { 'Z', new string[] { "ZZZZZ", "   Z ", "  Z  ", " Z    ", "ZZZZZ" } },
        { ' ', new string[] { "     ", "     ", "     ", "     ", "     " } }
    };

    static void Main()
    {
        Console.Write("Enter the text to display in large: ");
        string input = Console.ReadLine().ToUpper();

        // Iterate over each line of the banner
        for (int row = 0; row < 5; row++)
        {
            foreach (char c in input)
            {
                if (bannerChars.ContainsKey(c))
                {
                    Console.Write(bannerChars[c][row] + "  ");
                }
            }
            Console.WriteLine();
        }
    }
}

 Output

Enter the text to display in large: hello
H   H  EEEEE  L      L      OOO  
H   H  E      L      L     O   O 
HHHHH  EEEE   L      L     O   O 
H   H  E      L      L     O   O 
H   H  EEEEE  LLLLL  LLLLL  OOO  

Comparte este ejercicio de C#