Example #1
0
from Employee import Employee
from Person import Person

harris = Employee(14, 'harris', 25)
print(issubclass(Employee, Person))

print(isinstance(harris, Person))
print(isinstance(harris, Employee))

print(harris.__repr__())
print(harris.__str__())

han = Employee(14, 'harris', 25)
print(harris == han)
print(Employee._Employee__counter)
Example #2
0
from Person import Person
from Employee import Employee

roni = Employee(1, "ronizheng", 25)
print(issubclass(Employee, Person))
print(isinstance(roni, Person))
print(isinstance(roni, Employee))

print(roni.__repr__())  # 类型表达
print(roni.__str__())

mars = Employee(1, "ronizheng", 25)
print(mars == roni)
print(Employee._Employee__counter)
Example #3
0
from Employee import Employee
from temp5 import Person

mars = Employee("px", 30, 0)

print(issubclass(Employee, Person))
print(isinstance(mars, Employee))
print(isinstance(mars, Person))

print(mars.__repr__())
print(mars.__str__())

eleven = Employee("px", 30, 0)
print(mars == eleven)

print("-"*50)
print(mars.counter)
# print(Employee._Employee__counter)

a = [1, 2]
print(a)
# next(a)
b = iter(a)
print(next(b))
print(next(b))
# print(next(b))
while (True):
    user_input = raw_input("Enter the number:  \n1: To add the Employee detail \n2: To search Employee \n3: To delete Employee \n4: To Exit Program\n")

    if user_input == '0':
        break
    elif user_input == '1':
        print("Enter the following details of employee")
        name = raw_input("Name:  ")
        number = raw_input("Employee Number:  ")
        department = raw_input("Department Name:  ")
        dob = raw_input("Date of birth:  ")
        join_date = raw_input("Joined Date:  ")
        salary = raw_input("Employee Salary:  ")

        emp = Employee(name, number, department, dob, join_date, salary)
        print(type(emp.__str__()))
        print (type("Shankar"))
        file = open("employee_record.txt", 'a')

        file.write("%s%s" % (emp.__str__(),"\n"))
        file.close()


    elif user_input == '2':
        print ("Enter the Employee name to search")
        name = raw_input("Name:  ")
        with open('employee_record.txt') as f:
            for line in f:
                employee_name = line.split("|", 5)
                # print employee_name[0]
                if employee_name[0].lower() == name.lower():
Example #5
0
import json

from Employee import Employee


def say_hi(value):
    """Here is the comments for the function"""
    print(__name__)
    # print("Hi " + value)
    return "Hi " + value


# 将person转换为dict
def emp_2_json(emp):
    return {'name': emp.name, 'salary': emp.salary}


if __name__ == '__main__':
    rtn = say_hi("Tom")
    print("\n return is: " + rtn)

    emp = Employee("Tom", 2000)
    emp.display_count()
    emp.display_employee()
    print("emp=" + emp.__str__())

    emp_json = json.dumps(emp.__dict__)
    print("empJson=" + emp_json)
 def testEmployee(self):
     employeeTest = Employee("12345","Richard","Barney","1990","03","25","2015-11-02")
     employeeString = "12345\t\tRichard Barney\t\t1990-03-25\t2015-11-02"
     self.assertEqual(employeeString, employeeTest.__str__())
Example #7
0
from Employee import Employee

emp1 = Employee('Gagan', 'Naidu', 50000)

emp1.fullname = 'Keanu Reevs'

print(emp1.__repr__())
print(emp1.__str__())