Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coding Challenge - Python solution from Ziyi Cao #76

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions python/src/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
class Video:
"""A class used to represent a Video."""

def __init__(self, video_title: str, video_id: str, video_tags: Sequence[str]):
def __init__(self, video_title: str, video_id: str, video_tags: Sequence[str],
video_flagged=False, video_flagged_reason="Not supplied"):
"""Video constructor."""
self._title = video_title
self._video_id = video_id

self._flagged = video_flagged
self._flagged_reason = video_flagged_reason
# Turn the tags into a tuple here so it's unmodifiable,
# in case the caller changes the 'video_tags' they passed to us
self._tags = tuple(video_tags)
Expand All @@ -25,7 +27,30 @@ def video_id(self) -> str:
"""Returns the video id of a video."""
return self._video_id

@property
def flagged(self) -> bool:
"""Returns the video flag of a video."""
return self._flagged

@flagged.setter
def flagged(self, flag):
"""Set the video flag of a video."""
self._flagged = flag

@property
def flagged_reason(self) -> str:
"""Returns the video flagged_reason of a video."""
return self._flagged_reason if self._flagged else None

@flagged_reason.setter
def flagged_reason(self, reason="Not supplied"):
"""Set the video flagged_reason of a video."""
self._flagged_reason = reason

@property
def tags(self) -> Sequence[str]:
"""Returns the list of tags of a video."""
return self._tags

def __str__(self):
return f"{self.title} ({self.video_id}) [{' '.join(list(self.tags))}]"
Loading