Package butler :: Module wine
[hide private]
[frames] | no frames]

Source Code for Module butler.wine

 1  ''' 
 2  Created on Jul 19, 2011 
 3   
 4  @author: santtu 
 5  ''' 
 6   
7 -class Wine(object):
8 ''' 9 The class C{Wine} represents entries in a user's 10 wine diary. Each entry brings together a wine type and an 11 evaluation of that wine by the user. 12 13 A wine object is, in a way, immutable once created; there are no 14 methods to change any of its attributes. 15 ''' 16 17
18 - def __init__(self, name, description, price, rating):
19 ''' 20 Creates a new wine diary entry with the given attributes. 21 22 @param name: the name of the evaluated wine 23 @param description: a description of the wine 24 @param price: the price of a bottle of the wine 25 @param rating: the rating given to the wine 26 ''' 27 self.name = name 28 self.description = description 29 self.price = price 30 self.rating = rating
31
32 - def get_name(self):
33 ''' 34 Returns the name of the wine. 35 36 @return: wine name 37 ''' 38 return self.name
39 40 41 42 43
44 - def get_description(self):
45 ''' 46 Returns the description of the wine. 47 48 @return: wine description 49 ''' 50 return self.description
51 52 53
54 - def get_prize(self):
55 ''' 56 Returns the price of a bottle of the kind of wine 57 represented by this wine object. 58 59 @return: wine price 60 ''' 61 return self.price
62 63
64 - def get_rating(self):
65 ''' 66 Returns the rating given to the wine by a user. 67 68 @return: wine rating 69 ''' 70 return self.rating
71 72
73 - def get_value_for_money(self):
74 ''' 75 Returns the value-for-money index for the wine. The 76 index is equal to the rating of the wine divided by 77 the price of the wine. Thus, a higher value-for-money 78 index indicates better value for money. 79 80 @return: value-for-money index 81 ''' 82 if self.price == 0: 83 return 0 84 return self.rating / self.price
85 86
87 - def isbetter_than(self, another_wine):
88 ''' 89 Determines if the wine is better than another given 90 wine, based on the ratings given to the two wines. 91 92 @param another_wine: another wine to compare with 93 @return: a boolean value indicating if this wine has a higher 94 rating than the one given as a parameter 95 ''' 96 return self.rating > another_wine.rating
97