All pastes #409288 Raw Edit

Chippy

public python v1 · immutable
#409288 ·published 2007-03-25 15:52 UTC
rendered paste body
#!/usr/bin/python# -*- coding: utf-8 -*-# Filename : chippy.py#############################################  % Chippy trunk 5/03/07 %                ############################################## A till program for chip shops and such   ## Copyright Ben Goodger 2006-7             ## Licensed under the GPL v.2               ##   (http://www.gnu.org/copyleft/gpl.html) ########################################### #from os import name, system#Data structureclass Item:	def __init__(self,button,name,price):		self.name = name		self.button = button		self.price = price		#print "%s assigned to button %s costing £%.2f" % (self.name, self.button, self.price)		def name():		return self.name	def button():		return self.button	def price():		return self.price#Data readingitems = [	Item("q","Chips",1.10),	Item("w","Large Chips",1.55),	Item("e","Haddock",2.70),	Item("r","Cod",2.30),	Item("t","Breaded Plaice",2.70),	Item("u","Scampi",2.20),	Item("i","Fishcake",0.70), 	Item("o","Fish Finger",0.25),	Item("p","Cod Roe",0.80),	Item("a","Chicken Portion",2.30),	Item("s","Chicken Nuggets",1.80),	Item("d","Chickenburger",1.30),	Item("f","Beefburger",1.30),	Item("g","Double Chickenburger",3.00),	Item("h","Battered Burger",1.40),	Item("j","Cheeseburger",1.90),]#Clear screen functiondef cls(numlines=100):	if name == "posix":		# Unix/Linux/MacOS/BSD/etc		system('clear')	elif name in ("nt", "dos", "ce"):		# DOS/Windows		system('CLS')	else:		# Fallback for other operating systems.		print '\n' * numlines#Main loopdef main():	global item, total	item = raw_input()	for t in items:		if item == t.button:									print "%s - £%.2f" % (t.name, t.price)			total = total + t.price			undefined = False			break		elif item == "total" or item == "new" or item == "exit" or item == "quit":			undefined = False		else:			undefined = True	if undefined == True:				print "Undefined item %s" % item#Interface shizzcls() # Clear the screenprint "Welcome to Chippy\nCopyright © Ben Goodger 2006-7\n"print "Ready"item = "new"while item != "quit":	if item == "new":		total = 0.0	elif item == "total":		print "Total: £%.2f" % total		elif item == "exit" or item == "quit":		exit	main()