Source code for Restaurant

"""
    Restaurant class, uses the address class

"""

from Address import *

class Restaurant(object):
[docs] def __init__(self,name,latitude,longitude,address,url,category,ratings=list()): """ create new Restaurant object """ self.name = name self.latitude = latitude self.longitude = longitude self.address = Address(address) self.url = url self.category = category self.ratings = ratings
[docs] def __str__(self): """ create string of restaurant """ mystr = "" mystr = self.name + str(self.address) return mystr
[docs] def average_rating(self): """ return average rating for restaurant """ if len(self.ratings) == 0: return -1 return sum(self.ratings)/len(self.ratings)
[docs] def max_rating(self): """ return max rating for restaurant if it exists """ if len(self.ratings) == 0: return -1 maxValue = self.ratings[0] for i in range(1,len(self.ratings)): maxValue = max(maxValue,self.ratings[i]) return maxValue
[docs] def min_rating(self): """ return min rating for restaurant if it exists """ if len(self.ratings) == 0: return -1 return min(self.ratings)