def main(): print('1 - Add Employee') print('2 - Add Boss') print('3 - Print employees') print('4 - Remove employee by index') print('5 - Save company to file') print('6 - Read company to file') print('7 - Exit') company = Company() while True: command = input('Enter command: ') if command == '1': emp = Employee() company.add_employee(emp.read_from_console()) elif command == '2': boss = Boss() company.add_employee(boss.read_from_console()) elif command == '3': print(company) elif command == '4': index = int(input('Enter index: ')) del company.employees[index] elif command == '5': fname = input('Enter file name: ') company.write_to_file(fname) elif command == '6': fname = input('Enter file name: ') company = Company.read_from_file(fname) elif command == '7': break else: print('Wrong command!')
def add_employee_to_location(self, location): add_to_new_company = False # TODO Add criteria when new Company is created pass # if compares to == 1 not to == 0 to ignore the first company which # provides public charging for a location if len(location.companies) == 1: add_to_new_company = True company = Company() if add_to_new_company: company = self.add_company(location) else: company = random.choice(list(location.companies.values())[1:]) company.add_employee() return company
from company import Company from employee import Employee first_company = Company("REI", "800 Rock Way", "Outdoor Retail") second_company = Company("Lyft", "300 2nd Ave", "Rideshare") first_employee = Employee("Alyssa", "Outdoor Trip Leader", "02/23/20") first_company.add_employee(first_employee.name) second_employee = Employee("Matt", "Desk Manager", "01/04/20") first_company.add_employee(second_employee.name) third_employee = Employee("Stacey", "Sales Representative", "12/15/19") first_company.add_employee(third_employee.name) fourth_employee = Employee("Katie", "Customer Experience Associate", "03/20/20") second_company.add_employee(fourth_employee.name) fifth_employee = Employee("Sofia", "Critical Response Line Associate", "04/12/20") second_company.add_employee(fifth_employee.name) print( f"{first_company.name} is in the {first_company.industry} located at {first_company.address} and has the following employees:" ) for employee in first_company.employees: print(employee) print(