Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
4.4 kB
0
Indexable
Never
using System;

namespace TaxiService
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Random random = new Random();

            const int minPrice = 400;
            const float adjustment = 1.75f;

            Console.WriteLine("ОТКУДА: ");
            string? start = Console.ReadLine();

            Console.WriteLine("КУДА: ");
            string? end = Console.ReadLine();
            Console.WriteLine("Ваш заказ принят!");

            Console.WriteLine();

            float distanceKm = Convert.ToSingle(random.Next(6));
            float distanceM = Convert.ToSingle(random.Next(10));

            float load = Load();
            string? loadText = "";

            switch (load)
            {
                case 1:
                    loadText = "нет";
                    break;
                case 1.5f:
                    loadText = "маленькая";
                    break;
                case 2:
                    loadText = "средняя";
                    break;
                case 2.5f:
                    loadText = "большая";
                    break;
                default:
                    loadText = "ошибка";
                    break;
            }


            float price = (distanceKm + (distanceM / 100) / adjustment) * load * minPrice;


            if (price < minPrice)
            {
                price = minPrice;
            }

            Console.WriteLine($"Вы поедите c {start} до {end}. Расстояние - {distanceKm}.{distanceM} км");
            Console.WriteLine($"Сейчас {loadText} нагруженность");
            Console.WriteLine($"Стоимость поездки: {(int)price} тенге");
            Console.WriteLine();

            GetDriverData();
        }

        static float Load()
        {
            Random random = new Random();

            float[] loadNum = new float[] { 1, 1.5f, 2, 2.5f };

            int randomLoad = random.Next(loadNum.Length);

            return loadNum[randomLoad];
        }


        static void GetDriverData()
        {
            Random random = new Random();
            DriverData dd = new DriverData();

            int indexName = random.Next(dd.Name.Length);
            int indexCarMake = random.Next(dd.CarMake.Length);
            int indexColor = random.Next(dd.Color.Length);

            string name = dd.Name[indexName];
            string make = dd.CarMake[indexCarMake];
            string color = dd.Color[indexColor];

            int nomer = random.Next(001, 1000);
            string seria = "";

            char[] englishAlphabet = new char[]
            {
                'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
                'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
            };

            string[] numbers = new string[]
            {
                "01", "02", "03", "04", "05", "06", "07", "08", "09", "10",
                "11", "12", "13", "14", "15", "16", "17"
            };

            int indexNumber = random.Next(numbers.Length);
            string region = numbers[indexNumber];

            int i = 1;
            while (i <= 3)
            {
                int index = random.Next(englishAlphabet.Length);
                seria += englishAlphabet[index];
                i++;
            };

            Console.WriteLine($"Ваш водитель:\n" +
                $"{name}\n" +
                $"{make}\n" +
                $"{color}\n" +
                $"{nomer}{seria}{region}");
        }
    }

    class DriverData
    {
        public string[] Name = new string[]
       {
            "Bekzat",
            "Alikhan",
            "Nurdaulet",
            "Berik"
       };

        public string[] CarMake = new string[]
        {
            "Toyota Corolla",
            "Nissan GTR",
            "Toyota Crown",
            "Lada Vesta",
            "Lada 2114",
        };

        public string[] Color = new string[]
        {
            "Черный",
            "Белый",
            "Красный",
            "Серый",
        };
    }
}
Leave a Comment