Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A():
- def __init__(self, name):
- self.name=name
- def bounce(self):
- print "bounced"
- self.name=""
- del self
- class list_A():
- list1=[]
- def __init__(self,*name):
- for i in name:
- self.list1.append(A(i))
- def display(self):
- print "** list of employee:"
- for i in self.list1:
- print "- %s" % i.name
- def hire(self, newname):
- not_in_list=False
- for i in self.list1:
- if newname==i.name:
- print "%s already in Staff" % newname
- not_in_list=False
- return
- else:
- not_in_list=True
- if not_in_list==True:
- self.list1.append(A(newname))
- print "%s Hired"%newname
- def fire(self,newname):
- not_in_list=True
- idx=0
- for i in self.list1:
- if newname==i.name:
- print "%s found and fired "%newname
- i.bounce()
- self.list1.pop(idx)
- not_in_list=False
- return
- else:
- print "%s not in list" % newname
- not_in_list=True
- idx+=1
- if not_in_list==True:
- print "%s not found"%newname
- my_list=list_A("Tom","Jim","Lisa")
- my_list.display()
- my_list.hire("Greg")
- my_list.hire("Jim")
- my_list.fire("Jim")
- my_list.fire("John")
- my_list.hire("Bill")
- my_list.fire("Tom")
- my_list.display()
- # print my_list
- # print my_list.list1
- for i in my_list.list1:
- print i
- #del i
- i.bounce()
- print "deleted"
- print my_list.list1
Advertisement
Add Comment
Please, Sign In to add comment