Package butler ::
Module user
|
|
1 '''
2 Created on Jul 19, 2011
3
4 @author: santtu
5 '''
6
8 '''
9 The class C{User} represents users of the Butler wine
10 diary program. Each user has a number of wines that they have
11 tasted and rated.
12 '''
13
14
16 '''
17 Constructor. Creates a new user who has tasted no wines yet.
18 '''
19 self.tasted_wines = []
20
21
23 '''
24 Adds a new wine to the user's list of tasted wines.
25
26 @param new_wine: the new wine diary item to add
27 '''
28 if len(self.tasted_wines) == 0 or new_wine.isbetter_than(self.favorite):
29 self.favorite = new_wine;
30
31 self.tasted_wines.append(new_wine)
32
33
35 '''
36 Returns the wine that the user rated the highest, i.e.,
37 the wine which has the highest rating of the ones added
38 with method C{add_wine}. If there is a tie for
39 first place, the wine tasted first is returned.
40
41 @return: the user's favorite wine
42 '''
43 return self.favorite
44
45
46
48 '''
49 Returns a list of all the wines the user has tasted.
50
51 @return: the wines tasted by the user
52 '''
53 return self.tasted_wines;
54
55