diff --git a/app/main.py b/app/main.py index a740cca7..9c60d540 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,22 @@ class OnlineCourse: - # write your code here - pass + + def __init__(self, name: str, description: str, weeks: int) -> None: + self.name = name + self.description = description + self.weeks = weeks + + def __repr__(self) -> str: + return (f"Online course: {self.name}, " + f"Description: {self.description}, " + f"Weeks: {self.weeks}") + + @classmethod + def from_dict(cls, course_dict: dict) -> "OnlineCourse": + name = course_dict["name"] + description = course_dict["description"] + weeks = cls.days_to_weeks(course_dict["days"]) + return cls(name, description, weeks) + + @staticmethod + def days_to_weeks(days: int) -> int: + return (days + 6) // 7