All pastes #1828423 Raw Edit

clueless

public text v1 · immutable
#1828423 ·published 2010-03-08 11:20 UTC
rendered paste body
#!/usr/bin/pythonclass cart:	def __init__(self):		self.items = []		self.total = 0	def add2cart(self,item):		self.items.append(item)	def view(self):		print "This is your shoppingcart:\n------------------------"		_counter = 1		for item in self.items:			product,price = item			self.total += int(price)			print "%d. %-10s %-s SEK" % (_counter, product, price)			_counter += 1		print "\nTotal sum to pay: %d SEK" %  self.totalclass shop:	def __init__(self):		self.items = [('bananas','10'),('apples',20),('cheese',40),('bread',17),('juice',25)]		self.cart = cart()		print "Welcome to my shop, what can i offer you today?"	def listgrocery(self):		print "In this shop you can buy:\n"		counter = 1		for item in self.items:			product, price = item			print "%d. %-10s %-s SEK" % ( counter, product, price )			counter += 1	def dosomeshopping(self):		_choice = 99		while int(_choice) is not 0:			self.listgrocery()			_choice = raw_input("Enter number for product you want to buy or 0 when you are finished: ")			if int(_choice) is not 0:				self.cart.add2cart(self.items[int(_choice) - 1])				print "added one item to the shopping cart\n"		self.cart.view()				#mainloop_shop = shop()_shop.dosomeshopping()