Last active
November 7, 2016 07:15
-
-
Save lethargilistic/1bf85f64ba020f74fa76fc14fbac3b06 to your computer and use it in GitHub Desktop.
POC for something we shouldn't do. is_anime could come from the API call, I think.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _SeriesStatus: | |
def __init__(self, is_anime): | |
self.is_anime = is_anime | |
def __repr__(self): | |
return '{}(is_anime={})'.format(self.__class__.__name__, self.is_anime) | |
def __str__(self): | |
if self.is_anime: | |
return self.anime_string | |
else: | |
return self.manga_string | |
class Started(_SeriesStatus): | |
def __init__(self, is_anime): | |
self.is_anime = is_anime | |
self.status_code = 1 | |
self.manga_string = 'Publishing' | |
self.anime_string = 'Currently Airing' | |
class Finished(_SeriesStatus): | |
def __init__(self, is_anime): | |
self.is_anime = is_anime | |
self.status_code = 2 | |
self.manga_string = 'Finished' | |
self.anime_string = 'Finished Airing' | |
class Planned(_SeriesStatus): | |
def __init__(self, is_anime): | |
self.is_anime = is_anime | |
self.status_code = 3 | |
self.manga_string = 'Not Yet Published' | |
self.anime_string = 'Not Yet Aired' | |
def Series(num, is_anime): | |
if num == 1: | |
return Started(is_anime) | |
if num == 2: | |
return Finished(is_anime) | |
if num == 3: | |
return Planned(is_anime) | |
else: | |
raise NameError | |
started_anime = Series(1, True) | |
finished_anime = Series(2, True) | |
planned_anime = Series(3, True) | |
started_manga = Series(1, False) | |
finished_manga = Series(2, False) | |
planned_manga = Series(3, False) | |
print(started_anime.status_code, str(started_anime), repr(started_anime)) | |
print(finished_anime.status_code, str(finished_anime), repr(finished_anime)) | |
print(planned_anime.status_code, str(planned_anime), repr(planned_anime)) | |
print(started_manga.status_code, str(started_manga), repr(started_manga)) | |
print(finished_manga.status_code, str(finished_manga), repr(finished_manga)) | |
print(planned_manga.status_code, str(planned_manga), repr(planned_manga)) | |
''' | |
(1, 'Currently Airing', 'Started(is_anime=True)') | |
(2, 'Finished Airing', 'Finished(is_anime=True)') | |
(3, 'Not Yet Aired', 'Planned(is_anime=True)') | |
(1, 'Publishing', 'Started(is_anime=False)') | |
(2, 'Finished', 'Finished(is_anime=False)') | |
(3, 'Not Yet Published', 'Planned(is_anime=False)') | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
__eq__
would also need to be overridden, I think.