Skip to content

Instantly share code, notes, and snippets.

@DNDK
Last active December 28, 2019 12:37
Show Gist options
  • Save DNDK/33eec0d5501307e726edcf76ff0a34e7 to your computer and use it in GitHub Desktop.
Save DNDK/33eec0d5501307e726edcf76ff0a34e7 to your computer and use it in GitHub Desktop.
class Employe:
spn = 1
def __init__(self,n,sn,spn):
self.name = n
self.surname = sn
self.spn = spn #rank
def __del__(self):
print("Good bye, mr. ", self.name," ",self.surname)
emps = []
counter = 1
cmd = ""
print("Type /help to see commands")
while cmd !='/q':
cmd = input(">")
if cmd == "/help":
print("/q - quit\n"
"/add - add employee\n"
"/delete - dismiss employee\n"
"/giverank - increase employee's valuation\n"
"/look - look through the employees list")
elif cmd == "/add":
name = input("Enter employee's name:\n >")
surname = input("Enter employee's surname\n >")
value = int(input("Enter employee's valuation\n >"))
emp = Employe(name, surname, value)
emps.append(emp)
print("Employee added successful! His ID is #",counter)
counter+=1
elif cmd == "/delete":
ind = input("Enter employee's ID\n >")
try:
ind = int(ind)
ind -= 1
emps[ind].__del__()
emps.pop(ind)
print("Employee dismissed successful...\n")
except ValueError:
print("Incorrect ID!")
elif cmd == "/giverank":
ind = input("Enter employee's ID:\n >")
try:
ind = int(ind)
sp = input("Enter employee's new rank:\n >")
try:
sp = int(sp)
emps[ind-1].spn = sp
print("Success!")
except ValueError:
print("Incorrect rank")
except ValueError:
print("Incorrect ID")
elif cmd == "/q":
print("BYE")
elif cmd == "/look":
for i in emps:
print("Employee",i.name,i.surname,"Rank is", i.spn)
else:
print("Incorrect command!\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment