PDA

View Full Version : Halloween Hitlist :)


ChefNinja
10-18-2002, 06:53 AM
OK, this actually started out as a joke with a friend of mine. We were talking about taking paintball guns out on Halloween night and stirring up a little trouble. Anyways, as we were talking, I kept joking with him about how he just made my hitlist and such...

So then I decided I should write a hitlist keeper tracker thing! :D

Anyway.. its pretty sloppy.. but that doesn't matter cuz its not really meant for anything :P


class Hitlist:
def __init__(self):
try:
self.names = []
self.list = []
for line in open("hitlist.txt", "r").readlines():
self.names.append(line)

for item in self.names:
str = item
str2 = str[:-1]

self.list.append(str2)

except:
self.nlist = []

def add(self, name):
try:
if name in self.list:
print "Name already on hitlist:", name + "\n"

else:
self.list.append(name)
file=open("hitlist.txt", "w")
for item in self.list:
file.write(item+"\n")
file.close()

print "Added to hitlist:", name + "\n"
except:
print "Could not add to list"


def remove(self, name):
try:
if name in self.list:
self.list.remove(name)
file=open("hitlist.txt", "w")
for item in self.list:
file.write(item+"\n")
file.close()
print "Removed from hitlist:"+"\n", name
else:
print "Was not found on hitlist:"+"\n", name

except:
print "Could not remove from list:", name


def display(self):
try:
if len(self.list) > 0:
print "Current hitlist:\n"
for item in self.list:
print item
print "\n"

else:
print "No hitlist found\n"
except:
print "No hitlist found\n"



def printmenu():
print "-----------------------------"
print "1. Add person to hitlist"
print "2. Remove person from hitlist"
print "3. View hitlist"
print "9. Quit"

def add_person():
name = raw_input("\nName to add: ")
x = Hitlist()
x.add(name)
main()

def rem_person():
name = raw_input("\nName to remove: ")
x = Hitlist()
x.remove(name)
main()

def display_list():
print "\n"
x = Hitlist()
x.display()
main()


def main():
dict = {'1':'add_person()', '2':'rem_person()',
'3':'display_list()', '9':'sys.exit()'}

try:
printmenu()
choice = raw_input("Enter choice: ")
exec dict[choice]

except KeyError:
print "Must enter a valid choice.\n"
main()

if __name__ == '__main__':
main()


Enjoy making your new hitlist ;)

inkedmn
10-18-2002, 02:31 PM
heh, nice

recluse
10-18-2002, 03:59 PM
I may or may not have been thinking of a similar project (pesky Feds, have to be careful w/what one says) but I think you should add the option of being able to store why a person made it on to your hit-list. If you're like me this would be very handy with my poor memory and loads of people that need a good whoopin'.

polin8
10-20-2002, 01:34 AM
watch out you could get expelled for coding this;)

ChefNinja
10-20-2002, 07:27 PM
yer mom could get expelled... :p