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

Class Wine

object --+
         |
        Wine

The class Wine represents entries in a user's wine diary. Each entry brings together a wine type and an evaluation of that wine by the user.

A wine object is, in a way, immutable once created; there are no methods to change any of its attributes.

Instance Methods [hide private]
 
__init__(self, name, description, price, rating)
Creates a new wine diary entry with the given attributes.
 
get_name(self)
Returns the name of the wine.
 
get_description(self)
Returns the description of the wine.
 
get_price(self)
Returns the price of a bottle of the kind of wine represented by this wine object.
 
get_rating(self)
Returns the rating given to the wine by a user.
 
get_value_for_money(self)
Returns the value-for-money index for the wine.
 
isbetter_than(self, another_wine)
Determines if the wine is better than another given wine, based on the ratings given to the two wines.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, description, price, rating)
(Constructor)

 

Creates a new wine diary entry with the given attributes.

Parameters:
  • name - the name of the evaluated wine (string)
  • description - a description of the wine (string)
  • price - the price of a bottle of the wine (float)
  • rating - the rating given to the wine (int)
Overrides: object.__init__

get_name(self)

 

Returns the name of the wine.

Returns:
wine name (string)

get_description(self)

 

Returns the description of the wine.

Returns:
wine description (string)

get_price(self)

 

Returns the price of a bottle of the kind of wine represented by this wine object.

Returns:
wine price (float)

get_rating(self)

 

Returns the rating given to the wine by a user.

Returns:
wine rating (int)

get_value_for_money(self)

 

Returns the value-for-money index for the wine. The index is equal to the rating of the wine divided by the price of the wine. Thus, a higher value-for-money index indicates better value for money.

Returns:
value-for-money index (float)

isbetter_than(self, another_wine)

 

Determines if the wine is better than another given wine, based on the ratings given to the two wines.

Parameters:
  • another_wine - another wine to compare with
Returns:
a boolean value indicating if this wine has a higher rating than the one given as a parameter (boolean)