Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1 : Creating objects ( Classes ) 1 . Since there are multiple employees and because the same information needs to be saved and

Part 1: Creating objects (Classes)
1. Since there are multiple employees and because the same information needs to be saved and generated for each employee you will need to consider creating a Employee class. UML diagram below shows attributes and methods for the class you are to create
2. Attributes: The class is to be assigned 7 attributes. See list of attributes in UML diagram above.
The attributes that need to be defined when creating an instance are the empId, first_name , last_name, age, department and salary.
the email attributes will be assigned values via class methods. Further explanation is provided in step 3 below.
All attributes must be protected.
3. Methods : Make sure you have all necessary methods defined for the created class (__init__, getters , setters and __repr__)
The __repr__ method is to return a string that references values referenced in ALL the attributes.
The set_email method is to be used to assign a value to the email attribute.
i. Its to be automatically triggered/called when a new instance is created.
ii. It requires the employees last and first name as arguments.
iii. It generates the email by adding last_name+.+first_name+@abc_company.com)
iv. It returns the email it generated
For instance , if the employees first and last name is Oscar Wilde.
The email that should be generated would be as following wilde.oscar@abc_company.com
Make sure getters are created for all attributes.
4. Save the class in a file named employeeInfo.py
Part 2: Create the program
Create a menu driven program that does the following.
First it displays the Menu shown below
--------------Menu-----------------------------------
1) Read Employee Info and Create Class Objects/Instances
2) Add a New Employee Record
3) Update Employee Information
4) Search for Employee by Last Name
5) Search for Employee by Id
6) Generate Report
7) Exit
---------------------------------------------------------
After displaying the menu, the program is to ask the user to enter their choice.
4.1 If the user choose 1:
1. The program to call a read_file() function.
The read_file() function reads the content of the employees.csv file, one row at a time. As it reads each row , its to do the following:
Read each piece of information into a variable ( ex last name into a variable,...)
Create an Employee instance for each record/row
As instances are created, save them in a list
The function is to return a list that contains the objects/instances that were created.
Note that when creating instances, six arguments should be passed ( employee id, first name , last name , age, department and salary )
4.2 If the user chooses 2:
1. Call the read_file() function
Before adding a new employee , we need to check if the employee already exists. To do that however, the employee instances must have been created.
Because instance will only be created if user chooses option 1 when they first run the program , we need to make sure instances are created regardless of option user chooses first. You will therefore need to call the read_file() function here so that instances are created.
2. Ask the user to enter the employee Id.
3. Iterate over the list of objects that the read_file() function returned and check if the employee id the user entered already exists.
- if it exists , display a message that tells the user the employee already exists and cant be added
- if it doesnt exist (not found), move on to step 4
4. Ask user to enter the following
a. Employees id
b. Employees last name
c. Employees first name
d. Employees age
e. The department the employee will work in
f. The employees salary
5. Create an Employee instance.
6. Append new instance to the list of objects the read_file() function returned.
4.3 If the user chooses 3:
1. Call the read_file() function
Before updating employee information , we need to check if the employee already exists. To do that however, employee instances must have been created.
Because instance will only be created if user chooses option 1 when they first run the program , we need to make sure instances are created regardless of option user chooses first. You will therefore need to call the read_file() function here so that instances are created.
2. Ask the user to enter the employee Id.
3. Iterate over the list of objects that the read_file() function returned and check if the employee id the user entered already exists.
- if it doesnt exist , display a message that notifies the user that employee doesnt exist
- if the employee id
image text in transcribed

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions