CS1A Lab #6
Lab 6: Classes and Objects (50 points)
This lab will give you more experience on the use of:
classes
class methods
Lab 6: Employee Class [50 points]
Write a class named Employee that holds the following data about an employee in attributes:
name, ID number, department, and job title.
Once you have written the class, write a program that creates three Employee objects to hold the
following data:
Name ID Number Department Job Title
Susan Meyers 47899 Accounting Vice President
Mark Jones 39119 IT Programmer
Joy Rogers 81774 Manufacturing Engineer
The program should store this data in the three objects and then display the data for each
employee on the screen.
# Fill in this space to construct an Employee class
class Employee:
def __init__(self, name, id_number, department, title):
def set_name(self, name):
def set_id_number(self, id_number):
def set_department(self, department):
def set_title(self, title):
def get_name(self):
def get_id_number(self):
def get_department(self):
def get_title(self):
def __str__(self):
def main():
# Fill in this space to create three instances of Employee
print('Employee 1:')
print(emp1)
print()
print('Employee 2:')
print(emp2)
print()
print('Employee 3:')
print(emp3)
# Call the main function.
main()
Here is a sample run:
Employee 1:
Name: Susan Meyers
ID number: 47899
Department: Accounting
Title: Vice President
Employee 2:
Name: Mark Jones
ID number: 39119
Department: IT
Title: Programmer
Employee 3:
Name: Joy Rogers
ID number: 81774
Department: Manufacturing
Title: Engineer
Submission
1. Include the standard program header at the top of your Python file.
2. Submit your files to Etudes under the “Lab 6 “ category.
Employee.py
Standard program header
Each programming assignment should have the following header, with italicized text
appropriately replaced.
Note: You can copy and paste the comment lines shown here to the top of your assignment each
time. You will need to make the appropriate changes for each assignment (assignment number,
due date, and description).
* Program or Lab #: Insert assignment name
* Programmer: Insert your name
* Due: Insert due date
* CS21A, Summer 2014
* Description: (Give a brief description for Lab 6)