程序代写代做代考 Programming Exercise 3-1

Programming Exercise 3-1

Programming Exercise 10-4

# emp.py

class Employee:

def __init__(self, name, id_number, department, title):

self.__name = name

self.__id_number = id_number

self.__department = department

self.__title = title

def set_name(self, name):

self.__name = name

def set_id_number(self, id_number):

self.__id_number = id_number

def set_department(self, department):

self.__department = department

def set_title(self, title):

self.__title = title

def get_name(self):

return self.__name

def get_id_number(self):

return self.__id_number

def get_department(self):

return self.__department

def get_title(self):

return self.__title

def __str__(self):

result = ‘Name: ‘ + self.get_name() + \

‘\nID number: ‘ + self.get_id_number() + \

‘\nDepartment: ‘ + self.get_department() + \

‘\nTitle: ‘ + self.get_title()

return result

# Exercise 10-4.py

import emp

def main():

# Create three instances of Employee

emp1 = emp.Employee(‘Susan Meyers’, ‘47899’,

‘Accounting’, ‘Vice President’)

emp2 = emp.Employee(‘Mark Jones’, ‘39119’,

‘IT’, ‘Programmer’)

emp3 = emp.Employee(‘Joy Rogers’, ‘81774’,

‘Manufacturing’, ‘Engineer’)

print(‘Employee 1:’)

print(emp1)

print()

print(‘Employee 2:’)

print(emp2)

print()

print(‘Employee 3:’)

print(emp3)

# Call the main function.

main()