Я создал простое меню, которое должно вызывать классы и функции из оператора If. он просто печатает «А» каждый раз, когда я запускаю код. Я новичок в python OOP. Я также пробовал некоторые коды отсюда. В чем проблема с моим кодом?
class CustomError(Exception):
pass
class employee:
def menu(self):
print('\tA = To Add Employee Record')
print('\tB = To Update Employee Record')
print('\tC = To Increase Employee Salary')
print('\tD = To Generate Payslip')
print('\tX = Exit')
choice = input("\nType here! ").upper()
def exec_menu(self):
choice ="A"
while True:
if choice == "A":
rec = add_record #this is from another class
rec.employee_info()
elif choice =="B":
pass
elif choice == "C":
pass
elif choice == "D":
pass
elif choice =="X":
exit()
else:
print("Whong value the system will now exit!")
exit()
class add_record:
def employee_info(self):
print("Employee number must be 9 numbers long")
print("Name and Lastname must be charcters only")
print("Plese choose on this Department name: Accounting, Human Resources, Marketing, Finance, MIS, Admin")
while True:
print("*" * 70)
Employee_empno = int(input("Enter Unique number for your Employee Number:"))
Employee_last = str(input("Enter Lastname:"))
Employee_first = str(input("Enter Firstname:"))
Employee_dept = input("Enter Department:").upper()
Employee_rate = int(input("Enter Rate per hour:"))
with open('empRecord.txt', 'a') as f:
f.write(f"\n{Employee_empno}, {Employee_last}, {Employee_first}, {Employee_dept}, {Employee_rate};")
print("if you want add more Employee in Information press 1 ")
user_input = input("Enter:")
if user_input != "1":
records = add_record()
employee.menu(any)
Заранее спасибо!