Skip to content

Instantly share code, notes, and snippets.

@mmourafiq
Created January 28, 2013 13:06
Show Gist options
  • Save mmourafiq/4655366 to your computer and use it in GitHub Desktop.
Save mmourafiq/4655366 to your computer and use it in GitHub Desktop.
class Story(object):
"""
Story object
@type _cpt: int
@param _cpt: counts the number of instance created.
@type _height: int
@param _height: The stroy's height.
@type _time: int
@param _time: The time of publication.
@type _id: int
@param _id: The story's id.
@type _score: int
@param _score: The story's score.
@type _height: int
@param _height: The stroy's height.
@type _proportioned_score: float
@param _proportioned_score: The stroy's _score proportioned to height.
"""
__cpt = 0
def __init__(self, time=-1, score=-1, height=-1):
self._id = Story.__cpt
self._time = time
self._score = score
self._height = height
self._proportioned_score = float(score)/height
Story.__cpt += 1
def __repr__(self):
return "id: %s, time: %s" % (self._id, self._time)
def __gt__(self, story):
if(self._proportioned_score > story._proportioned_score):
return True
if(self._proportioned_score < story._proportioned_score):
return False
if(self._id < story._id):
return True
return False
def _better_score(self, story):
if(self._score > story._score):
return True
if(self._score < story._score):
return False
if(self._id < story._id):
return True
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment