[Tutor] lunch.py
Christopher Spears
cspears2002 at yahoo.com
Tue Feb 7 17:50:36 CET 2006
I'm working on a program where a Customer orders Food
from an Employee. Here is what I have so far:
class Food:
def __init__(self, name):
Food.foodName = name
class Customer:
def __init__(self,name):
Customer.name = name
def placeOrder(self, employee, food):
print "%s, I want, %s please! " % Employee.name,
food.foodName
class Employee:
def __init__(self, name):
Employee.name = name
class Lunch:
def __init__(self):
self.employee = Employee('Dave')
def order(self, name, foodName):
customer = Customer(name)
food = Food(foodName)
customer.placeOrder(self.employee, food)
if __name__ == '__main__':
meal = Lunch()
meal.order('Chris', 'spam')
When I run the program, I get the following error
Traceback (most recent call last):
File "lunch.py", line 25, in ?
meal.order('Chris', 'spam')
File "lunch.py", line 21, in order
customer.placeOrder(self.employee, food)
File "lunch.py", line 9, in placeOrder
print "%s, I want, %s please! " % Employee.name,
food.foodName
I've tested the program, and I know that Employee.name
is getting through, but for some reason, food.foodName
is not. What am I doing wrong?
More information about the Tutor
mailing list