Untitled

mail@pastecode.io avatar
unknown
csharp
a month ago
4.5 kB
0
Indexable
Never
internal class Program
{
    private static void Main()
    {
        Console.WriteLine("Hello World");

        Apartment[] apartments = new Apartment[]
        {
            new Apartment(
                "3-х комнатная в ЖК",
                "Kazakhstan, Atyrau",
                new Room[]
                {
                    new Room("Ванная", width: 100,height: 200, length: 300, doorCount: 1, windowCount: 2),
                    new Room("Спальня", width: 200,height: 100, length: 250, doorCount: 1, windowCount: 1),
                    new Room("Кухня", width: 325,height: 125, length: 100, doorCount: 2, windowCount: 0),
                    new Room("Detskaia", width: 300,height: 300, length: 200, doorCount: 3, windowCount: 3),
                }), 
            new Apartment(
                "3-х комнатная в ЖК",
                "Kazakhstan, Atyrau",
                new Room[]
                {
                    new Room("Ванная", width: 100,height: 200, length: 300, doorCount: 1, windowCount: 2),
                    new Room("Спальня", width: 200,height: 100, length: 250, doorCount: 1, windowCount: 1),
                    new Room("Кухня", width: 325,height: 125, length: 100, doorCount: 2, windowCount: 0),
                    new Room("Detskaia", width: 300,height: 300, length: 200, doorCount: 3, windowCount: 3),
                }),

    };


        while (true)
        {
            Console.Clear();

            Console.WriteLine();

            Console.WriteLine("Добро пожаловать!");
            Console.WriteLine("Выберите апартаменты: ");
           
            int index = 0;

            foreach (var apartment in apartments)
            {
                index++;
                Console.WriteLine($"{index}. {apartment.Name}");
            }

            int inputApartment = Convert.ToInt32( Console.ReadLine());

            if (inputApartment > 0 || inputApartment <= apartments.Length)
            {
                Console.Clear();

                Console.WriteLine($"Вы выбрали {apartments[inputApartment - 1].Name}");
                Console.WriteLine($"Местоположение: {apartments[inputApartment - 1].Location}");
                Console.WriteLine($"Количество комнат: {apartments[inputApartment - 1].Rooms.Length}");
                apartments[inputApartment - 1].ShowRooms();
                apartments[inputApartment - 1].ChoiceRoom();
            }
            else
                Console.WriteLine("Неизвестная команда");
                    break;
            }

            Console.WriteLine("Для продолжения нажмите любую клавишу");
            Console.ReadKey();
        }
    }

/// 

class Room
{
    public string Name;
    public float Width;
    public float Height;
    public float Length;
    public int DoorCount;
    public int WindowCount;

    public Room(string name, float width, float height, float length, int doorCount, int windowCount)
    {
        Width = width;
        Height = height;
        Length = length;
        DoorCount = doorCount;
        WindowCount = windowCount;
        Name = name;
    }
        public void ShowInfo()
    {
        Console.WriteLine();
        Console.WriteLine($"komnata: {Name}");
        Console.WriteLine($"Razmery: {Width} cm, {Height} cm, {Length} cm");
        Console.WriteLine($"Kolichestvo okon: {WindowCount}");
    }
}

class Apartment
{
    public string Name;
    public string Location;
    public Room[] Rooms;

    public Apartment(string name, string location, Room[] rooms)
    {
        Name = name;
        Location = location;
        Rooms = rooms;
    }

    public void ShowRooms()
    {
        int index = 0;

        foreach (Room room in Rooms)
        {
            index++;

            Console.WriteLine($"{index}. {room.Name} [{(room.Length / 100) * (room.Width / 100)} kv.m.]");
        }
    }


    public void ChoiceRoom()
    {
        Console.WriteLine("Viberite komnaty: ");

        int inputRoom = Convert.ToInt32(Console.ReadLine());

        if (inputRoom > 0 || inputRoom <= Rooms.Length)
        {
            Rooms[inputRoom - 1].ShowInfo();
        }
        else
        {
            Console.WriteLine("Neizvestnaia komnata");
        }
    }
}
Leave a Comment