Example #1
0
#!/usr/bin/python

from employee import Employee 

emp1 = Employee("Bob", 50000);
emp2 = Employee("Mary", 60000);

print emp1;
print emp2;

emp1.displayEmployee();
emp2.displayEmployee();
emp1.displayCount();

# Because python is dynamic and all you can add attributes to an 
# existing instance
emp1.age = 25;

def emp(age, competence):
    employee = Employee()
    employee.age = age
    employee.competence = competence
    return employee
    if usrname in un_list:
        dup = True
        usrname = gen_un(emp_fname, emp_lname, emp_birthyr, dup)

    # adding all the username to the list by appending
    un_list.append(usrname)

    # Calling the Employee class for each set of employee
    # Then call the gen_pw function from Employee class to generate password
    employee_list = Employee(employee[0], employee[1], employee[2],
                             employee[3], employee[4], employee[5])
    passwd = employee_list.gen_pw()

    # from the employee list running the function greetings and age from Person class
    # then adding them to the new list
    em_tuple = (employee_list.greetings(), employee_list.age())
    em_greet_age_list.append(em_tuple)

    # creating a list of all information of employee and password
    # then using the username as the key for a dictionary
    em_db = [emp_fname, emp_lname, emp_birthyr, passwd]
    employee_dict[usrname] = em_db

######### removed with function gen_un() #########
# moving to function section and recreating as a function def
#
#un_first_init = emp_fname[0].lower()
#un_lname = emp_lname.lower()
#un_birthyr_2d = emp_birthyr[-2] + emp_birthyr[-1]
#
#username = un_first_init + un_lname + un_birthyr_2d