Return to Home Page
      Blog     Consulting     Seminars     Calendar     Books     CD-ROMS     Newsletter     About     FAQ      Search
 

I know its probably early stages, but in the code


class Espresso(Decorator):
cost = 0.75f
description = " espresso"
public Espresso(DrinkComponent):
Decorator.__init__(self, component)

the 0.75f doesn't compile in python 2.1, nor does the keyword public.
f  e  x


Class attributes are found by the instance attribute look-up rules rather than the plain symbol look-ups.
Should be:

def getTotalCost(self):
return self.component.getTotalCost() + self.cost

def getDescription(self):
return self.component.getDescription() +
self.description

f  e  x


The constructor should probably be:

def __init__(self, drinkComponent):
    self.component = drinkComponent

(as in the next paragraph)

f  e  x



Add your comment below. Use an empty line between each paragraph. Paragraphs will be automatically formatted, and single carriage returns will be respected. Use <code> to begin a code block, and </code> to end a code block. Your email address will not be visible to spam harvesters or used in any way except to contact you with further questions.

Your Email Address:

Search     Home     WebLog     Consulting     Seminars     Calendar     Books     CD-ROMS     Newsletter     About     Contact     Site Design     Server Maintenance     Powered by Zope
©2007 MindView, Inc.