Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python EmployeedB class You need to write an EmployeeDB class that maintains the database of all university employees and departments. As part of this

image text in transcribedin python

EmployeedB class You need to write an EmployeeDB class that maintains the database of all university employees and departments. As part of this assignment, you have been given an EmployeeDB class with driver code. You need to write your code in the given EmployeeDB class. It must contain: 1. The class constructor will receive the filename and use it to create an instance of the class. It will also initialize an empty employee dictionary emp_dict and an empty employee object list emp_obj_list. You will hide all three instance variables (make them private by adding the double underscore preceding the variable names). 2. The read_file method will read the csv file (filename was passed to the constructor). It will store the file contents in emp_dict. For each row of the csv file, cells in the first column (SNo) will be added as keys. The cells from the remaining columns will be added as values in the dictionary in the form of a list. In the end, this method will print ' xx records added to the dictionary.', where xx is the length of the dictionary. Example: The first record of the employeeInfo.csv file is "1, Will, Bradshaw, Biology, 2016-06-04". The read_file will save this record as emp_dict[' 1 '] = ['Will', 'Bradshaw', 'Biology', '2016-06-04']. 3. There will be one accessor method: get_obj_lst. It will return the employee object list emp_obj_list. 4. The emp_exists method will receive an employee object and check if the emp_obj_list contains another employee object with identical attribute values (first name, and last name). It will return the index of the identical employee object if found, otherwise, it will return 1. 5. The add_emp_data method will read the employee dictionary emp_dict and add the unique employees to the employee object list emp_obj_list. Please note that for each record (value as a list) in the dictionary, the first two attribute values (first name, and last name - all strings) represent an employee object. The remaining two attribute values represent a department object (department name - string, and joining date - string). This method will use the emp_exists method to check if the employee object with identical values already exists in the emp_obj_list or not. If the current record represents a unique employee not currently in the emp_obj_list, then a new employee object will be added to the emp_obj_list. In addition, you will add the department object to its respective employee object. To summarize, for each record in the dictionary: (a) You create a new employee object (this will generate a new incremental employee id). (b) You add the newly created employee object to the emp_obj_list if it does not exist in the list already. (c) In case the employee object already exists in the list, the newly incremental employee id should be decremented (because we never used the newly created employee object). You use the decrementEmpID method of the Employee class to decrement the emID by 1. (d) You create and add the department object to its respective employee object using the add_dept method of the Employee class. (e) In the end, this method will print 'xx unique employees added to the database.', where xx is the number of unique employees added to the emp_obj_list. 6. The print_cross_emp method will print the information of employees who are cross-appointed in more than one department. If such records are found in the emp_obj_list, the method will print Record XX found!, where XX is the number of such records found so far. Following this print statement, the method will print the employee object. The method will then print 4 Appointments found: followed by the respective department objects. To print the employee objects and department objects, the method should make use of their respective _str_ methods. The printing format can be seen in the included screenshots. 7. The remove_emp method will receive an employee id and remove the employee if it exists in the emp_obj_list. If the employee is found, then it will remove the employee object and print 'Successfully removed employee with employee id: xx ', where xx is the input employee id. Otherwise, it will print 'Employee not found?'. 8. The date_diff method will receive an employee id and check if the employee is cross-appointed or not i.e., the employee is appointed in more than one department or not. If the employee is not cross-appointed, then the method will print Employee is not cross-appointed.. Otherwise, the method will compute the maximum differences between the joining dates of the crossappointments. The maximum difference is defined as the number of days between the

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genomes And Databases On The Internet A Practical Guide To Functions And Applications

Authors: Paul Rangel

1st Edition

189848631X, 978-1898486312

More Books

Students also viewed these Databases questions