0% found this document useful (0 votes)
46 views2 pages

CPAS 211L - Assignment 1

The document describes an introduction to object-oriented programming and classes. It instructs the reader to create an Employee class with variables for an employee's name, ID number, department, and position. The class should include different constructors to initialize the variables in different ways, as well as mutator and accessor functions. The reader is then asked to write a program that creates three Employee objects storing sample data and displays the data for each employee.

Uploaded by

mirror
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views2 pages

CPAS 211L - Assignment 1

The document describes an introduction to object-oriented programming and classes. It instructs the reader to create an Employee class with variables for an employee's name, ID number, department, and position. The class should include different constructors to initialize the variables in different ways, as well as mutator and accessor functions. The reader is then asked to write a program that creates three Employee objects storing sample data and displays the data for each employee.

Uploaded by

mirror
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Laboratory Activity 1

Introduction to Classes

BACKGROUND

Procedural programming is a method of writing software. It is a programming practice centered on the


procedures or actions that take place in a program. Object-oriented programming is centered around the
object. Objects are created from abstract data types that encapsulate data and functions together.

A class is code that specifies the attributes and member functions that a particular type of object may have.
Think of a class as a “blueprint” that objects may be created from. It serves a similar purpose as the blueprint
for a house. The blueprint itself is not a house, but is a detailed description of a house. When we use the
blueprint to build an actual house, we could say we are building an instance of the house described by the
blueprint.

PART I – Programming challenge

Employee Class: 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, employee’s ID number, department, and position.
• A constructor that accepts the following values as arguments and assigns them to the appropriate
member variables: employee’s name and ID number. The department and position fields
should be assigned an empty string ( " " ).
• A default constructor that assigns empty strings ( " " ) to the name , department , and position
member variables, and 0 to the idNumber member variable.

Write appropriate mutator functions that store values in these member variables and accessor functions
that return the values in these member variables. Once you have written the class, write a separate
program that creates three Employee objects to hold the following data.

1
Name ID Number Department Position
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.

You might also like