Answered step by step
Verified Expert Solution
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 : Creating objects Classes
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
Attributes: The class is to be assigned attributes. See list of attributes in UML diagram above.
The attributes that need to be defined when creating an instance are the empId, firstname lastname, age, department and salary.
the email attributes will be assigned values via class methods. Further explanation is provided in step below.
All attributes must be protected.
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 setemail method is to be used to assign a value to the email attribute.
i Its to be automatically triggeredcalled when a new instance is created.
ii It requires the employees last and first name as arguments.
iii. It generates the email by adding lastnamefirstname@abccompany.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@abccompany.com
Make sure getters are created for all attributes.
Save the class in a file named employeeInfo.py
Part : Create the program
Create a menu driven program that does the following.
First it displays the Menu shown below
Menu
Read Employee Info and Create Class ObjectsInstances
Add a New Employee Record
Update Employee Information
Search for Employee by Last Name
Search for Employee by Id
Generate Report
Exit
After displaying the menu, the program is to ask the user to enter their choice.
If the user choose :
The program to call a readfile function.
The readfile function reads the content of the employeescsv 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 recordrow
As instances are created, save them in a list
The function is to return a list that contains the objectsinstances that were created.
Note that when creating instances, six arguments should be passed employee id first name last name age, department and salary
If the user chooses :
Call the readfile 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 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 readfile function here so that instances are created.
Ask the user to enter the employee Id
Iterate over the list of objects that the readfile 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
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
Create an Employee instance.
Append new instance to the list of objects the readfile function returned.
If the user chooses :
Call the readfile 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 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 readfile function here so that instances are created.
Ask the user to enter the employee Id
Iterate over the list of objects that the readfile 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started