diff --git a/app/main.py b/app/main.py index a740cca7..02482fa3 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,21 @@ +from __future__ import annotations +import math + + class OnlineCourse: - # write your code here - pass + def __init__(self, name: str, description: str, weeks: float) -> None: + self.name = name + self.description = description + self.weeks = weeks + + @staticmethod + def days_to_weeks(days: int) -> int: + return math.ceil(days / 7) + + @classmethod + def from_dict(cls, course_dict: dict) -> OnlineCourse: + days = course_dict["days"] + weeks = cls.days_to_weeks(days) + return cls(name=course_dict["name"], + description=course_dict["description"], + weeks=weeks)