UML Diagram of class Employee
Screenshot(employee_App)
Program(employee_App.py)
from employee import Employee
import os.path
from os import path
#function display user choices and return correct choice
def getMenu():
print("OPTIONS:\n-------")
print('1. Look up an employee\n2. Add a new
employee\n3. Change an existing employee\n4. Delete an employee\n0.
Quit\n')
opt=int(input('Enter your choice: '))
while(opt<0 or opt>4):
print('ERROR!!!Option
should be 0-4.Try again!!!')
opt=int(input('Enter
your choice: '))
return opt
#Function read data from file and add into dictionary of
employee
#Her key is employee id
def readData(employees):
file1 = open('employees.dat', 'r')
while True:
line = file1.readline()
.strip()
if not line:
break
line=line.split(',')
employees[line[1]]=Employee.add(line[0],line[1],line[2],line[3])
file1.close()
#Search an employee in dictionary using id
#If found display employee details
#Otherwise eroor message
def lookUp(employees):
id=input('\nEnter employee id for look up:
')
if id in employees:
print(employees[id])
else:
print(id,' not
present!!!')
#Add a new employee in dictionary
#Check already present before add
def addEmployee(employees):
id=input('\nEnter employee id: ')
if id in employees:
print('Already
present!!!')
else:
name=input('Enter
name: ')
dep=input('Enter
department: ')
title=input('Enter
job title: ')
emp=Employee()
emp.add(name,id,dep,title)
employees[id]=emp
print('Added a new
employee!!!')
return employees
#Update name,department and title of an employee using id
def updateEmployee(employees):
id=input('\nEnter employee id: ')
if id in employees:
name=input('Enter
name: ')
dep=input('Enter
department: ')
title=input('Enter
job title: ')
emp=Employee()
emp.add(id,name,dep,title)
employees[id]=emp
print('Change
employee with id ',employees.get(id).ID_number)
else:
print(id,' not
present!!!')
return employees
#Remove an employee from dictionary using id
def deleteEmployee(employees):
id=input('\nEnter employee id to delete
')
if id in employees:
employees.pop(id)
print(id,'
removed!!')
else:
print(id,' not
present!!!')
return employees
#Write dictionary details into file
def writeData(employees):
file1 = open('employees.dat', 'w')
for id in employees:
file1.write(employees[id].name+','+employees[id].ID_number+','+employees[id].department+','+employees[id].job_title+'\n')
file1.close()
#Main function
def main():
#Display header
print('***** Welcome To Employee App
*****\n')
#Create a dictionary
employees={}
#Check file exist
if path.exists('employees.dat'):
readData(employees)
#Call menu
opt=getMenu()
#Loop until exit
while opt!=0:
#Each options
if(opt==1):
lookUp(employees)
elif opt==2:
employees=addEmployee(employees)
elif opt==3:
employees=updateEmployee(employees)
elif opt==4:
employees=deleteEmployee(employees)
#repetittion
print()
opt=getMenu()
#Write into file
writeData(employees)
#Start here
if __name__=="__main__":
main()
Screenshot(employee.py)
Program(employee.py)
class Employee():
#Constructor
def __init__(self):
self.__name=""
self.__ID_number=""
self.__department=""
self.__job_title=""
#Add an employee
def add(self,name,id,depart,title):
self.name=name;
self.ID_number=id
self.department=depart
self.job_title=title
#Search an employee using id
def search(self,id):
return
self.ID_number==id
#Setters
def setName(self,name):
self.name=name
def setDepartment(self,depart):
self.department=depart
def setTitle(self,title):
self.job_title=title
#Display en amployee in string format
def __str__(self):
return "Name: %s, ID: %s,
Department: %s, Job title:
%s"%(self.name,self.ID_number,self.department,self.job_title)
Output
***** Welcome To Employee App *****
OPTIONS:
-------
1. Look up an employee
2. Add a new employee
3. Change an existing employee
4. Delete an employee
0. Quit
Enter your choice: 1
Enter employee id for look up: e1
e1 not present!!!
OPTIONS:
-------
1. Look up an employee
2. Add a new employee
3. Change an existing employee
4. Delete an employee
0. Quit
Enter your choice: 2
Enter employee id: e1
Enter name: Kaisy
Enter department: EC
Enter job title: Junior PC
Added a new employee!!!
OPTIONS:
-------
1. Look up an employee
2. Add a new employee
3. Change an existing employee
4. Delete an employee
0. Quit
Enter your choice: 1
Enter employee id for look up: e1
Name: Kaisy, ID: e1, Department: EC, Job title: Junior PC
OPTIONS:
-------
1. Look up an employee
2. Add a new employee
3. Change an existing employee
4. Delete an employee
0. Quit
Enter your choice: 3
Enter employee id: e1
Enter name: Kaisy
Enter department: EC
Enter job title: Senior
Change employee with id Kaisy
OPTIONS:
-------
1. Look up an employee
2. Add a new employee
3. Change an existing employee
4. Delete an employee
0. Quit
Enter your choice: 1
Enter employee id for look up: e1
Name: e1, ID: Kaisy, Department: EC, Job title: Senior
OPTIONS:
-------
1. Look up an employee
2. Add a new employee
3. Change an existing employee
4. Delete an employee
0. Quit
Enter your choice: 4
Enter employee id to delete e1
e1 removed!!
OPTIONS:
-------
1. Look up an employee
2. Add a new employee
3. Change an existing employee
4. Delete an employee
0. Quit
Enter your choice: 1
Enter employee id for look up: e1
e1 not present!!!
OPTIONS:
-------
1. Look up an employee
2. Add a new employee
3. Change an existing employee
4. Delete an employee
0. Quit
Enter your choice: 0
Press any key to continue . . .
1. Write a class named Employee that holds the following data about an employee in attributes:...
please make sure to write down all the coding and the output for it and to do all three steps Student Name: 1. Write a class named Employee that holds the following data about an employee in attributes: name, ID number, department, and job title. (employee.py) 2. Create a UML diagram for Employee class. (word file) 3. Create a program that stores Employee objects in a dictionary. Use the employee ID number as the key. (employee_App.py) The program should present...
Using C++, Write a class named Employee that has the following member variables: name. A string that holds the employee's name. idNumber. An int variable that holds the employee's ID number. department. A string that holds the name of the department where the employee works. position. A string that holds the employee's job title. The class should have the following constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name,...
Design and write a class named Employee that inherits the Person class from the previous exercise and holds the following additional data: ID number, department and job title. Once you have completed the Employee class, write a Python program that creates three Employee objects to hold the following data: Name ID Number Department Job Title Phone Susan Meyers 47899 Accounting Vice President 212-555-1212 Mark Jones 39119 IT Programmer 212-555-2468 Joy Rogers 81774 Operations Engineer 212-555-9753 The Python program should store...
Use python to create this program. 1) Employee Class Write an Employee class that keeps data attributes for the following pieces of information: Note: For all classes, the attributes must be hidden Employee Name Employee Number Hire Date Create accessors and mutators Attributes should be hidden. Create a class attribute that determines a standard pay rate adjustment 4% for raises 2) ProductionWorker Class Write a class named ProductionWorker that is a subclass of Employee that holds the following attributes .Shift...
It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming Challenge 2 Employee Class.pdf Program Template: // Chapter 13, Programming Challenge 2: Employee Class #include <iostream> #include <string> using namespace std; // Employee Class Declaration class Employee { private: string name; // Employee's name int idNumber; // ID number string department; // Department name string position; // Employee's position public: // TODO: Constructors // TODO: Accessors // TODO: Mutators }; // Constructor #1 Employee::Employee(string...
Create a c++ code and answer number 1 Homework Ch. 13 - Employee Class 30 points Design a class named Employee that has the following attributes: * Name ID Number- (Employee's] Identification Number " Department-the name of the department where the employee works " Position-the employee's job title The class should have the following constructors: A constructor that accepts values for all the member data as arguments A constructor that accepts the following values as arguments and assigns them to...
Create a C# Console program. Add a class named Employee that has the following public fields: • Name. The name field references a String object that holds the employee’s name. • IDNumber. The IDNumber is an int that holds the employee’s ID number. • Department. The department field is a String that holds the name of the department where the employee works. • Position. The position field is a String that holds the employee’s job title. Once you have written...
Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...
project-8c Write a class named Employee that has data members for an employee's name, ID_number, salary, and email_address (you must use those names - don't make them private). Write a function named make_employee_dict that takes as parameters a list of names, a list of ID numbers, a list of salaries and a list of email addresses (which are all the same length). The function should take the first value of each list and use them to create an Employee object....
Create a date class with attributes of month, day, and year. Create an employee class for storing information related to employee information for the CS1C Corporation. This class should contain the employee’s name, employee’s Id, phone number, age, gender, job title, salary, and hire date. You should write a series of member functions that change the employee’s name, employee’s Id, phone number, age, job title, salary, and hire date. You should use your date class (composition) when accessing hire date....