dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[DotGNU]Banner in C#


From: CH Gowri Kumar
Subject: [DotGNU]Banner in C#
Date: Fri, 29 Nov 2002 02:41:27 +0530 (IST)

> Does someone want to do it (to learn C# , of course...) ?..
Please find banner.cs as attachment.
Currently it handles only alphabets and that too uppercase letters(even
if u give lower case letters it converts them to uppercase and other than 
alpahbets are not displayed".


bash$ cscc banner.cs -o banner
bash$ ilrun banner "njoy pnet"

###### #    #      #  ####   #   #        #####  #    # ######  #####
#      ##   #      # #    #   # #         #    # ##   # #         #
#####  # #  #      # #    #    #          #    # # #  # #####     #
#      #  # #      # #    #    #          #####  #  # # #         #
#      #   ## #    # #    #    #          #      #   ## #         #
###### #    #  ####   ####     #          #      #    # ######    #


Regards,
Gowri Kumar
using System;

class Banner

{

        static int [] map  = new int[]{

         0, 0, 0, 0, 0, 0,

        12,18,33,63,33,33,

        62,33,62,33,33,62,

        30,33,32,32,33,30,

        62,33,33,33,33,62,

        63,32,62,32,32,63,

        63,32,62,32,32,32,

        30,33,32,39,33,30,

        33,33,63,33,33,33,

         4, 4, 4, 4, 4, 4,

         1, 1, 1, 1,33,30,

        33,34,60,36,34,33,

        32,32,32,32,32,63,

        33,51,45,33,33,33,

        33,49,41,37,35,33,

        30,33,33,33,33,30,

        62,33,33,62,32,32,

        30,33,33,37,34,29,

        62,33,33,62,34,33,

        30,32,30, 1,33,30,

        31, 4, 4, 4, 4, 4,

        33,33,33,33,33,30,

        33,33,33,33,18,12,

        33,33,33,45,51,33,

        33,18,12,12,18,33,

        17,10, 4, 4, 4, 4,

        63, 2, 4, 8,16,63

        };



        public void Show(string str)

        {

                const int MAXLENGTH = 11;

                int iter,oldLength,newLength=0;

                

                iter = str.Length/MAXLENGTH;

                str  = str.ToUpper();

                

                Console.WriteLine("");

                

                 do{

                        oldLength = newLength;

                        newLength = oldLength + MAXLENGTH;

                        

                        if(newLength > str.Length)

                                newLength = oldLength + (str.Length - 
oldLength);       

                        

                        for(int row = 0;row < 6; row++)

                {

                        

                                for(int j=oldLength;j<newLength;j++)

                                {

                        

                                        int offset=0;

                                        if( ('A'<=str[j]) && (str[j] <= 'Z'))

                                                offset=(str[j]-'A')*6+6+row;

                                        

                                        for(int q=5;q>=-1;--q)

                                        {

                    

                                                Console.Write("{0}",( q>=0 && 
((map[offset]&1<<q) > 0) ? '#' :' '));

                        

                                        }

                                }

                        

                                Console.WriteLine("");

                }

                

                        Console.WriteLine("");

                        iter--;

        

                        }while(iter >= 0 )

        }

}



class BannerApp

{

        public static void Main(String[] args)

        {

                Banner b;

                b = new Banner();

                

                if(args.Length == 0)

                        Console.WriteLine("Usage: banner <Your Text>");

                

                for(int i=0; i<args.Length;i++)

                {

                        b.Show(args[i]);

                        Console.WriteLine();

                }

        }

}

        

        


reply via email to

[Prev in Thread] Current Thread [Next in Thread]