AKOSH044

mail@pastecode.io avatar
unknown
csharp
a month ago
2.2 kB
1
Indexable
Never
//Vsevdonim
using UtilityRandom = Utility.Random;
internal class Program
{
    private static void Main(string[] args)
    {
        UtilityRandom random = new UtilityRandom();

        while (true)
        {
            Console.Clear();    

            Console.WriteLine(random.RandomInt);
            Console.WriteLine(random.RandomFloat);
            Console.WriteLine(random.RandomBool);
            Console.WriteLine(random.RandomDouble);
            Console.WriteLine(random.RandomCharV1);
            Console.WriteLine(random.RandomCharV2); 
            Console.WriteLine(random.RandomString);

            Thread.Sleep(50); //zapusk
        }
    }
}

namespace Utility
{
    public class Random
    {


        //Full-Property
        public int RandomInt => new System.Random().Next();
        public double RandomDouble => new System.Random().NextDouble() * Double.MaxValue;
        public float RandomFloat => new System.Random().NextSingle() * Single.MaxValue;
        public bool RandomBool
        {
            get
            {
                System.Random random = new System.Random();
                bool result = random.Next(2) == 0 ? true : false;

                return result;
            }

        }
        public char RandomCharV1
        {
            get
            {
                string characters = "qwertyuiopasdfghjklzxcvbnm";

                System.Random random = new System.Random();

                return characters[random.Next(characters.Length)];
            }

        }
        public char RandomCharV2
        {
            get
            {
                System.Random random = new System.Random();


                return (char)random.Next(97, 123);
            }

        }
        public string RandomString
        {
            get
            {
                string result = string.Empty;
                for (int i = 0; i < 10; i++)
                {
                    result += RandomCharV2;
                }
                return result;

            }

        }



    } 
}


////Alternative :Auto-Property
///public int RandomInt {get; set;}
Leave a Comment