21 Aralık 2014 Pazar

C# Console ( Maksat Eğlence Olsun :D )

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace beep
{
    class Program
    {
        static void Main(string[] args)
        {

            while (true)
            {
                int randommMin = 1, randommMax = 6;
                Int32 randomm = new Random().Next(randommMin, randommMax);

                Console.ForegroundColor = Program.GetColor(randomm);

                Console.WriteLine("\t{0}{1} {2} {3}", CreateSpace(randomm, randommMax), CreateStar(randomm), (char)3, CreateStar(randomm));

                Thread.Sleep(25);
            }

         
        }
        static ConsoleColor GetColor(int sayilar)
        {
            sayilar %= 5;
            switch (sayilar)
            {
                case 1: return ConsoleColor.Red;
                case 2: return ConsoleColor.Green;
                case 3: return ConsoleColor.Blue;
                case 4: return ConsoleColor.Yellow;
                default: return ConsoleColor.Cyan;
            }
        }

        static string CreateStar(int nStar)
        {
            string yildiz = String.Empty;
            return yildiz.PadLeft(nStar, '*');
        }

        static string CreateSpace(int n, int nMax)
        {
            if (n > nMax)
            {
                return String.Empty;
            }

            string spaces = String.Empty;
            return spaces.PadLeft((nMax - n), ' ');
        }
    }
}

Paylaş:

0 yorum:

Yorum Gönder

Popüler

Son

Kategoriler

Arşiv