Dauren

mail@pastecode.io avatar
unknown
csharp
22 days ago
7.8 kB
1
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.ReadLine();

        //

        Apartment[] apartments = new Apartment[]
        {
            new Apartment(
                "3-х комнатная в ЖК",
                "Kazakhstan, Atyrau",
                new Room[]
                {
                    new Room("Ванная",new Size(100, 200, 300),
                    new Window[]
                    {
                        new Window(new Size(30, 20, 10), Material.Plastic),
                    },
                    new Door[]
                    {
                        new Door(new Size(30, 20, 10), Material.Plastic)
                    }),
                    new Room("Спальня",new Size(200, 100, 250),
                        new Window[]
                    {
                        new Window(new Size(30, 20, 10), Material.Plastic),
                    },
                    new Door[]
                    {
                        new Door(new Size(30, 20, 10), Material.Plastic),
                    }),
                    new Room("Кухня", new Size(200, 100, 250),
                      new Window[]
                    {
                        new Window(new Size(30, 20, 10), Material.Plastic),
                    },
                    new Door[]
                    {
                        new Door(new Size(30, 20, 10), Material.Plastic)
                    }),
                    new Room("Detskaia", new Size(200, 100, 250),
                      new Window[]
                    {
                        new Window(new Size(30, 20, 10), Material.Plastic),
                    },
                    new Door[]
                    {
                        new Door(new Size(30, 20, 10), Material.Plastic)
                    }),
                }),
            new Apartment(
                "3-х комнатная в ЖК",
                "Kazakhstan, Atyrau",
                new Room[]
                {
                    new Room("Ванная", new Size(200, 100, 250),
                    new Window[]
                    {
                        new Window(new Size(30, 20, 10), Material.Plastic),
                    },
                    new Door[]
                    {
                        new Door(new Size(30, 20, 10), Material.Plastic)
                    }),
                    new Room("Спальня", new Size(200, 100, 250),
                    new Window[]
                    {
                        new Window(new Size(30, 20, 10), Material.Plastic),
                    },
                    new Door[]
                    {
                        new Door(new Size(30, 20, 10), Material.Plastic)
                    }),
                    new Room("Кухня", new Size(200, 100, 250),
                    new Window[]
                    {
                        new Window(new Size(30, 20, 10), Material.Plastic),
                    },
                    new Door[]
                    {
                        new Door(new Size(30, 20, 10), Material.Plastic)
                    }),
                    new Room("Detskaia", new Size(200, 100, 250),
                    new Window[]
                    {
                        new Window(new Size(30, 20, 10), Material.Plastic),
                    },
                    new Door[]
                    {
                        new Door(new Size(30, 20, 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();


        }
    }
}

/// 
/// okna
/// wirina
/// Visota
/// Material
///
///  ///
///
///  dver
/// wirina
///   vysota
/// material
///

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($"komnata: {Name}");
        Console.WriteLine($"Razmery(W,H,L): {Size.Width} cm, {Size.Height} cm, {Size.Length} cm");
        Console.WriteLine($"Kolichestvo okon: {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()
    {
        int index = 0;

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

            Console.WriteLine($"{index}. {room.Name} [{(room.Size.Length / 100) * (room.Size.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");
        }
    }
}
struct Size
{
    public float Width;
    public float Height;
    public float Length;

    public Size(float width, float height, float length)
    {
        Width = width;
        Height = 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