"""
Problem 1: Logging Decorator
Write a decorator called mylogging that logs the arguments and return value of a function.
"""
import logging
import functools

def mylogging(func):
    """Decorator to log function calls, including arguments and function name."""
    
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        logger = logging.getLogger(__name__)
        logger.debug(f"Calling {func.__name__} with args: {args}, kwargs: {kwargs}")
        result = func(*args, **kwargs)
        logger.debug(f"{func.__name__} returned: {result}")
        return result
    
    return wrapper


"""
Problem 2: BMI Calculator
Write a class called Person that has 3 attributes: name, height, and weight. The class should have
"""
class Person:
    """
    A class representing a person with name, height (in meters), and weight (in kilograms).
    The BMI (Body Mass Index) is dynamically calculated using the formula:
        BMI = weight / (height ** 2)
    """
    
    def __init__(self, name, height, weight):
        self.name = name
        self.height = height
        self.weight = weight
    
    @property
    def BMI(self):
        """Calculates and returns the BMI of the person."""
        return self.weight / (self.height ** 2)

"""
Problem 3: Linear Model
Write a class called LinearModel that has 2 attributes: m and b. The class should have
"""
class LinearModel:
    """
    A class representing a simple linear model following the equation:
        y = mx + b
    where:
        - m is the slope
        - b is the intercept
        - x is the input variable
    """
    
    def __init__(self, m, b):
        self.m = m
        self.b = b
    
    def predict(self, x):
        """Returns the predicted value y for the given input x using the equation y = mx + b."""
        return self.m * x + self.b