2017. november 26., vasárnap

2017.11.24. Nyílt napi óra - új anyag: beágyazott metódushívás

A Mátrix egy kezdeti verziója :)

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

namespace matrix
{
    class Program
    {
        static bool[] betuk = new bool[80];
        static Random rnd = new Random();
        static void tombFeltoltes()
        {
            for (int i = 0; i < 80; i++)
            {
                if (rnd.Next(0, 2) == 0)
                {
                    betuk[i] = true;
                }
                else
                {
                    betuk[i] = false;
                }
            }
        }

        static void characterRain()
        {
            Console.ForegroundColor = ConsoleColor.Green;
            int i = 0;
            while (true)
            {
                for (int j = 0; j < 80; j++)
                {
                    if (betuk[j])
                    {
                        Console.Write(Convert.ToChar(rnd.Next(32, 127)));
                    }
                    else
                    {
                        Console.Write(' ');
                    }
                }
                Thread.Sleep(100);

                i++;

                if (i % 30 == 0)
                {
                    tombFeltoltes();
                }
            }
        }

        static void Main(string[] args)
        {
            characterRain();
            Console.ReadLine();
        }
    }

}