In article <[EMAIL PROTECTED]>,
 Christopher Spears <[EMAIL PROTECTED]> wrote:

> When I run the program, I get the following error [snip]

The simple mechanical error is that when you're substituting more than 
one value, you need to wrap the value list in parens:

      print "%s, I want, %s please! " % (Employee.name, food.foodName)

(from Customer.placeOrder())


At this point your program, as written, gives the expected output. There 
is a more serious conceptual error, though. In your various __init__() 
methods, you are assigning the name attribute of the *class*, rather 
than the name of the *instance*.

That is, you are saying "the name of all employees is Dave" rather than 
"the name of this employee is Dave."

class Employee:
   def __init__(self, name):
      Employee.name = name  # <-- assigns class attribute (name of all 
Employees)

To illustrate, try running this as your __main__:

if __name__ == '__main__':
   meal = Lunch()
   meal.order('Chris', 'spam')
   # next line shouldn't replace Dave, but it does
   firedEmployee = Employee("Bill")
   meal.order('Jake', 'eggs')

In your __init__() methods, you should assign to self instead of to the 
class. For example:

class Employee:
   def __init__(self, name):
      self.name = name  # <-- assigns instance attribute (this 
Employee's name)

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to