public FloorPlan GenerateFloorPlan()
        {
            RoomNode main = GenerateValidRoom(RoomType.LivingRoom);

            int bedrooms  = (int)Constraints.GenerateValue("BedRooms");
            int bathrooms = (int)Constraints.GenerateValue("Bathrooms");
            int kitchens  = (int)Constraints.GenerateValue("Kitchens");

            // generate bed rooms
            for (int i = 0; i < bedrooms; i++)
            {
                main.Children.AddFirst(GenerateValidRoom(RoomType.BedRoom));
            }

            // genrate bathroom
            for (int i = 0; i < bathrooms; i++)
            {
                main.Children.AddFirst(GenerateValidRoom(RoomType.Bathroom));
            }

            // generate kitchen
            for (int i = 0; i < kitchens; i++)
            {
                main.Children.AddFirst(GenerateValidRoom(RoomType.Kitchen));
            }

            return(main.ToFloorPlan());
        }
        private RoomNode GenerateValidRoom(RoomType type)
        {
            RoomNode room = new RoomNode(type);

            switch (type)
            {
            case RoomType.LivingRoom:
                room.Area = (int)Constraints.GenerateValue("AreaLivingRooms");
                break;

            case RoomType.BedRoom:
                room.Area = (int)Constraints.GenerateValue("AreaBedRooms");

                // If constraints told us we get an extra room, lets add it (closet
                // is an example of an extra room)
                if ((int)Constraints.GenerateValue("ExtraRoom") > 0)
                {
                    room.Children.AddFirst(GenerateValidRoom(RoomType.ExtraRoom));
                }

                break;

            case RoomType.Kitchen:
                room.Area = (int)Constraints.GenerateValue("AreaKitchens");
                break;

            case RoomType.Bathroom:
                room.Area = (int)Constraints.GenerateValue("AreaBathrooms");
                break;

            case RoomType.ExtraRoom:
                room.Area = (int)Constraints.GenerateValue("AreaCloset");
                break;
            }
            return(room);
        }