GetLetter() public static method

public static GetLetter ( ) : char
return char
コード例 #1
0
ファイル: PlayerSetup.cs プロジェクト: ItsOliMate/Battleships
        public static void Setup()
        {
            Random random = new Random();

            // Destroyer 1 Random Coordinates

            char playersCoordinates1 = RandomLetter.GetLetter(0, 3);
            int  playersCoordinates2 = random.Next(2, 7);

            Destroyer1.Add(playersCoordinates1 + Convert.ToString(playersCoordinates2 - 1));
            Destroyer1.Add(playersCoordinates1 + Convert.ToString(playersCoordinates2));
            Destroyer1.Add(playersCoordinates1 + Convert.ToString(playersCoordinates2 + 1));
            Destroyer1.Add(playersCoordinates1 + Convert.ToString(playersCoordinates2 + 2));

            // Battleship Random Coordinates

            char playersCoordinates3 = RandomLetter.GetLetter(4, 6);
            int  playersCoordinates4 = random.Next(2, 7);

            BattleShip.Add(playersCoordinates3 + Convert.ToString(playersCoordinates4 - 2));
            BattleShip.Add(playersCoordinates3 + Convert.ToString(playersCoordinates4 - 1));
            BattleShip.Add(playersCoordinates3 + Convert.ToString(playersCoordinates4));
            BattleShip.Add(playersCoordinates3 + Convert.ToString(playersCoordinates4 + 1));
            BattleShip.Add(playersCoordinates3 + Convert.ToString(playersCoordinates4 + 2));

            // // Destroyer 2 Random Coordinates

            var playersCoordinates5 = RandomLetter.GetLetter(6, 9);
            var playersCoordinates6 = random.Next(2, 7);

            Destroyer2.Add(playersCoordinates5 + Convert.ToString(playersCoordinates6 - 1));
            Destroyer2.Add(playersCoordinates5 + Convert.ToString(playersCoordinates6));
            Destroyer2.Add(playersCoordinates5 + Convert.ToString(playersCoordinates6 + 1));
            Destroyer2.Add(playersCoordinates5 + Convert.ToString(playersCoordinates6 + 2));
        }
コード例 #2
0
        private void tmrPizzazNumbers_Tick(object sender, EventArgs e) // displays random numbers
        {
            Random rnd = new Random();

            lblFirstNumber.Text = rnd.Next(Convert.ToInt32(txtMin.Text), (Convert.ToInt32(txtMax.Text) + 1)).ToString();
            if (rnd.Next(0, 2) == 0)
            {
                randomLetter        = RandomLetter.GetLetter().ToString();
                lblFirstNumber.Text = randomLetter;
            }
            lblSecondNumber.Text = rnd.Next(Convert.ToInt32(txtMin.Text), (Convert.ToInt32(txtMax.Text) + 1)).ToString();
            if (rnd.Next(0, 2) == 0)
            {
                randomLetter         = RandomLetter.GetLetter().ToString();
                lblSecondNumber.Text = randomLetter;
            }
            lblThirdNumber.Text = rnd.Next(Convert.ToInt32(txtMin.Text), (Convert.ToInt32(txtMax.Text) + 1)).ToString();
            if (rnd.Next(0, 2) == 0)
            {
                randomLetter        = RandomLetter.GetLetter().ToString();
                lblThirdNumber.Text = randomLetter;
            }
            lblFourthNumber.Text = rnd.Next(Convert.ToInt32(txtMin.Text), (Convert.ToInt32(txtMax.Text) + 1)).ToString();
            if (rnd.Next(0, 2) == 0)
            {
                randomLetter         = RandomLetter.GetLetter().ToString();
                lblFourthNumber.Text = randomLetter;
            }
            lblFifthNumber.Text = rnd.Next(Convert.ToInt32(txtMin.Text), (Convert.ToInt32(txtMax.Text) + 1)).ToString();
            if (rnd.Next(0, 2) == 0)
            {
                randomLetter        = RandomLetter.GetLetter().ToString();
                lblFifthNumber.Text = randomLetter;
            }
        }
コード例 #3
0
    // Start is called before the first frame update
    void Start()
    {
        numbersLeft = numberOfLetters;
        characters  = new List <char>();
        while (numberOfLetters > 0)
        {
            characters.Add(RandomLetter.GetLetter());
            numberOfLetters--;
        }

        projector.text = characters[numberOfLetters].ToString().ToUpper();
    }
コード例 #4
0
        public void BinaryMultipleTest()
        {
            string path  = @"../../words.txt";
            var    lines = File.ReadLines(path).ToList();

            BinarySearch search = new BinarySearch();

            for (int i = 0; i < 10001; i++)
            {
                var searchItem = RandomLetter.GetLetter();
                search.Binary(searchItem, lines);
                Assert.IsNotNull(search);
            }
        }
コード例 #5
0
        public void SearchMultipleLinearTest()
        {
            string path  = @"../../words.txt";
            var    lines = File.ReadLines(path).ToList();

            LinearSearch search = new LinearSearch();

            for (int i = 0; i < 10001; i++)
            {
                var searchItem = RandomLetter.GetLetter();
                search.SearchLinear(searchItem, lines);
            }
            Assert.IsNotNull(search);
        }
コード例 #6
0
ファイル: day5.cs プロジェクト: adagr/Advent-of-Code
        static public void part2()
        {
            MD5 md5   = MD5.Create();
            int index = 0;

            char[] password = new char[8] {
                '-', '-', '-', '-', '-', '-', '-', '-'
            };
            while (true)
            {
                byte[]        inputBytes = Encoding.ASCII.GetBytes("abbhdwsy" + index);
                byte[]        hash       = md5.ComputeHash(inputBytes);
                StringBuilder sb         = new StringBuilder();
                for (int i = 0; i < hash.Length; i++)
                {
                    sb.Append(hash[i].ToString("X2"));
                }
                string s = sb.ToString();
                if (s.Substring(0, 5) == "00000")
                {
                    int pos;
                    if (Int32.TryParse(s[5].ToString(), out pos) && pos < 8 && password[pos] == '-')
                    {
                        password[pos] = s[6];
                    }
                }
                if (index % 10000 == 0)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        if (password[i] != '-')
                        {
                            Console.Write(password[i]);
                        }
                        else
                        {
                            Console.Write(RandomLetter.GetLetter());
                        }
                    }
                    Console.Write("\r");
                }
                index++;
            }
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: rubertsmann/StadtLandFluss2
        public void startGame()
        {
            timer1.Restart();
            timer2.Start();
            round++;
            lblRound.Text     = "Runde: " + round;
            start_Buchstabe   = RandomLetter.GetLetter();
            lblBuchstabe.Text = "Buchstabe: " + Char.ToString(start_Buchstabe);

            txtStart.Enabled = false;
            txtEnd.Enabled   = false;
            Stats.Enabled    = false;

            txtFluss.Enabled = true;
            txtLand.Enabled  = true;
            txtStadt.Enabled = true;
            txtStadt.Text    = "";
            txtLand.Text     = "";
            txtFluss.Text    = "";
        }
コード例 #8
0
ファイル: day5.cs プロジェクト: adagr/Advent-of-Code
        static public void part1()
        {
            MD5         md5 = MD5.Create();
            int         index = 0, count = 0;
            List <char> password = new List <char>();

            while (true)
            {
                byte[]        inputBytes = Encoding.ASCII.GetBytes("abbhdwsy" + index);
                byte[]        hash       = md5.ComputeHash(inputBytes);
                StringBuilder sb         = new StringBuilder();
                for (int i = 0; i < hash.Length; i++)
                {
                    sb.Append(hash[i].ToString("X2"));
                }
                string s = sb.ToString();
                if (s.Substring(0, 5) == "00000")
                {
                    count++;
                    password.Add(s[5]);
                }

                if (index % 10000 == 0)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        if (i < count)
                        {
                            Console.Write(password[i]);
                        }
                        else
                        {
                            Console.Write(RandomLetter.GetLetter());
                        }
                    }
                    Console.Write("\r");
                }
                index++;
            }
        }