Untitled

mail@pastecode.io avatar
unknown
csharp
a month ago
7.5 kB
3
Indexable
Never
internal class Program
{
    private static void Main()
    {
        //


        float number = 100;

        Test newTest = new Test(10);

        newTest.ChangeFloat(ref number);

        Console.WriteLine(number);

        Console.ReadKey();

        //

        Apartment[] apartments = new Apartment[]
        {
            new Apartment(
                "3-х комнатная в ЖК",
                "Kazakhstan, Atyrau",
                new Room[]
                {
                    new Room("Ванная", new Size(10,10,10),
                        new Window[]
                        {
                            new Window(new Size(10,10,10), Material.Plastic)
                        },
                        new Door[]
                        {
                            new Door(new Size(10,10,10), Material.Wood),
                        }),
                    new Room("Спальня", new Size(10,10,10),new Window[]
                        {
                            new Window(new Size(10,10,10), Material.Plastic)
                        },
                        new Door[]
                        {
                            new Door(new Size(10,10,10), Material.Plastic),
                        }),
                    new Room("Кухня", new Size(10,10,10),
                        new Window[]
                        {
                            new Window(new Size(10,10,10), Material.Plastic),
                            new Window(new Size(10,10,10), Material.Plastic),
                        },
                        new Door[]
                        {
                            new Door(new Size(10,10,10), Material.Plastic),
                        }),
                }),
            new Apartment(
                "4-х комнатная в ЖК",
                "Kazakhstan, Atyrau",
                new Room[]
                {
                    new Room("Ванная", new Size(10,10,10),
                        new Window[]
                        {
                            new Window(new Size(10,10,10), Material.Plastic)
                        },
                        new Door[] { new Door(new Size(10,10,10), Material.Plastic) }),
                    new Room("Спальня", new Size(10,10,10),
                        new Window[]
                        {
                            new Window(new Size(10,10,10), Material.Plastic)
                        },
                        new Door[] { new Door(new Size(10,10,10), Material.Plastic) }),
                    new Room("Кухня", new Size(10,10,10),
                        new Window[]
                        {
                            new Window(new Size(10,10,10), Material.Plastic)
                        },
                        new Door[] { new Door(new Size(10,10,10), Material.Plastic) }),
                    new Room("Детская", new Size(10,10,10),
                        new Window[]
                        {
                            new Window(new Size(10,10,10), Material.Plastic)
                        },
                        new Door[] { new Door(new Size(10,10,10), Material.Plastic) }),
                }),
    };

        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("Неизвестный апартамент");
            }


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

/// 
/// ОКНА
/// Ширина
/// Высота
/// Материал
///
/// ///
/// 
/// ДВЕРЬ
/// Ширина
/// Высота
/// Материал
///

class Door
{
    public Size Size;
    public Material Material;

    public Door(Size size, Material material)
    {
        Size = size;
        Material = material;
    }
}

class Window
{
    public Size Size;
    public Material Material;

    public Window(Size size, Material material)
    {
        Size = size;
        Material = material;
    }
}

class Room
{
    public string Name;
    public Size Size;
    public Window[] Windows;
    public Door[] Doors;

    public Room(string name, Size size, Window[] windows, Door[] doors)
    {
        Name = name;
        Size = size;
        Windows = windows;
        Doors = doors;
    }

    public void ShowInfo()
    {
        Console.WriteLine();
        Console.WriteLine($"Комната: {Name}");
        Console.WriteLine($"Размеры (Ш,В,Д): {Size.Width} см, {Size.Heigth} см, {Size.Length} см");
        Console.WriteLine($"Количество дверей: {Doors.Length}");
        Console.WriteLine($"Количество окон: {Windows.Length}");
    }
}

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()
    {
        Console.WriteLine();

        int index = 0;

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

            Console.WriteLine($"{index}. {room.Name} [{(room.Size.Length / 100) * (room.Size.Width / 100)} кв.м.]");
        }
    }

    public void ChoiceRoom()
    {
        Console.WriteLine();
        Console.Write("Выберите комнату: ");

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

        if (inputRoom > 0 || inputRoom <= Rooms.Length)
        {
            Rooms[inputRoom - 1].ShowInfo();
        }
        else
        {
            Console.WriteLine("Неизвестная комната");
        }
    }
}

struct Size
{
    public float Width;
    public float Heigth;
    public float Length;

    public Size(float width, float height, float length)
    {
        Width = width;
        Heigth = height;
        Length = length;
    }
}

enum Material
{
    None,
    Plastic,
    Wood
}

class Test
{
    public float Value;

    public Test(float value)
    {
        Value = value;
    }

    public void ChangeFloat(ref float value)
    {
        value = 0;
    }
}
Leave a Comment