Lukket

Lab 10

Lab 10 Due: 12/ 05/04, 10:00 pm

**Objectives:

**Inheritance

Over-riding base class methods

Polymorphism

Dynamic memory allocation

## Deliverables

Lab 10 Due: 12/ 05/04, 10:00 pm

**Objectives:

**Inheritance

Over-riding base class methods

Polymorphism

Dynamic memory allocation

**Program:** This lab is an exercise on Inheritance and Polymorphism. Use the base class Employee that you created in Lab08. Declare two derived classes.

**1.** *Faculty* that inherits the members of the base class plus has some more private members and public methods of its own.

**2.***Staff* that inherits the members of the base class plus has some more private members and public methods of its own.** Base Class Employee:

**Use *Employee* class as base class in this project. You may add a private data member type to the data members

**Derived Class Faculty:

**Add another header file, name it *Faculty.h* include“Employee.h?? at the beginning of this file, and declare class *Faculty* derived from the Employee class. The syntax is given below:

**Syntax:** class Faculty : public Employee

The class faculty should have the following members:

**Private members:

** Title (Professor, Associate Professor, Assistant Professor, Lecturer)

You may declare an enum data type to include all the titles (optional)

Salary

Department

**Public methods:

** Default constructor

Initialize Title to “Assistant??, Salary to 0, Department to “unknown??.

Note: The constructor of the base class will be invoked automatically to initialize the first, last, middle and the social security number for each of the objects of the faculty class.

Overloaded constructor:

Faculty (string, string, char, string, string, double, string)

Store the given values in private members. Use the overloaded constructor of the base class to assign the name and ssno (see class notes).

3 set methods,

To set the Title

Salary

Department

Display_object(): This method over-rides the display_object() method of the base class. Its task is to display the data stored in the faculty object to screen. It will invoke the display_object( ) method of the base class to display the name and ssno.

**Derived Class Staff:

**Add another header file, name it *Staff.h* include“Employee.h?? at the beginning of this file, and declare class *staff* derived from the Employee class.

The class Staff should have the following members:

**Private members:

** Department

Salary

Benefits

**Public methods:

** Default constructor

Initialize Department to “unknown??, salary to 0, and benefits to false

Note: The constructor of the base class will be invoked automatically to initialize the first, last, middle and the social security number for each of the objects of the Staff class.

Overloaded constructor:

Staff (string, string, char, string, string, double, bool)

Store the given values in private members. Use the overloaded constructor of the base class to store the name and ssno data (see class notes)

3 set methods

Department

Salary

Benefits

Display_object(): This method over-rides the display_object() method of the base class. Its task is to display the data stored in the faculty object to screen. It will invoke the display_object( ) method of the base class to display the name and ssno.

**Driver Program:

**To test your classes, write the main() function in [url removed, login to view] file, include “Faculty.h?? and Staff.h. The other header files like iostream, iomanip,math.h and string are already included in the file Faculty / Staff header file.

In the main() function:

a) Declare a named constant SIZE to store the number of employees = 3.

b)Declare a static array *purdue_emp* of Employee pointers:

Employee * purdue_emp{SIZE];.

c) Declare 3 Employees as follows:

a. An employee of the base class: Tala T. Jones, 111-11-1111.

b. A faculty employee: David J. Goldberg, 222-22-2222, Professor, 90,000, math

c. A staff employee: cathy. Use appropriate member functions to assign these values to cathy:

Cathy F. Davis, 333-33-3333, 39500, CIT, true

d) Display each of these objects using the display_object methods.

e) Make each array element point to one of these objects.

f) Use a for loop to go through the array elements and display each object being pointed by the array element.

g) Change the display_object method of the base class to **virtual**, and run the program again. You should notice that Polymorphism takes place and for each object its own method gets triggered.

**Grading Chart:

**Make sure the program output is clear and in readable format

Your code will be also graded based on clarity, proper indentation, good variable names, and documentation (some initial and inline comments)

all the required data member and member functions should be present.

* Make sure the program output is clear and in readable format.

* Code should be clear, with proper indentation, good variable names, and documentation (some initial and inline comments)

* To get full credit, all the required data member and member functions should be present. There will be a penalty for each missing part.

| Topic | Break-down |

| Employee class | |

| Faculty class = 10 | Syntax = 2

Default constructor = 1

Overloaded constructor = 2

3 set methods = 3

.display object = 2 |

| Staff class = 10 | Syntax = 2

Default constructor = 1

Overloaded constructor = 2

3 set methods = 3

display object = 2 |

| Main() function = 10 | Declare array of pointers to base class objects (-2 if wrong)

Declare 3 employees as specified = 3

Assign values to staff member = 2

Make array elements to point to them = 2

Write a loop to display array elements = 3 |

1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.

2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):

a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.

b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.

3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).

## Platform

Microsoft Visual Studio .Net 2003

Evner: .NET, C programmering, Ingeniørarbejde, Microsoft, MySQL, PHP, Software Arkitektur, Software Testning, Visual Basic, Windows Skrivebord

Se mere: your party assistant, wrong header, web project documentation format, web programming salary, virtual pointers, virtual functions cpp, virtual functions and polymorphism, virtual constructor, virtual char, the party staff, syntax programming, syntax in programming, string j, string in cpp, string functions in cpp, string cpp, string c plus plus, static programming, software for dynamic programming, salary benefits

Om arbejdsgiveren:
( 0 bedømmelser ) United States

Projekt ID: #3137867

18 freelancere byder i gennemsnit $32 på dette job

ghumber

See private message.

$25.5 USD på 1 dag
(108 bedømmelser)
5.9
eothman

See private message.

$31.45 USD på 1 dag
(76 bedømmelser)
5.8
SUog

See private message.

$17 USD på 1 dag
(104 bedømmelser)
5.8
classixsoftuk

See private message.

$85 USD på 1 dag
(70 bedømmelser)
5.6
codernextvw

See private message.

$17 USD på 1 dag
(58 bedømmelser)
5.5
enmaniac

See private message.

$8.5 USD på 1 dag
(41 bedømmelser)
4.3
vsagesoftware

See private message.

$8.5 USD på 1 dag
(27 bedømmelser)
3.9
saoromant

See private message.

$25.5 USD på 1 dag
(24 bedømmelser)
3.8
rrsoftvw

See private message.

$12.75 USD på 1 dag
(42 bedømmelser)
3.8
linuxhacker

See private message.

$10.2 USD på 1 dag
(18 bedømmelser)
3.8
vw1632457vw

See private message.

$38.25 USD på 1 dag
(7 bedømmelser)
2.0
dk

See private message.

$25.5 USD på 1 dag
(4 bedømmelser)
1.9
newcoder1

See private message.

$11.05 USD på 1 dag
(1 bedømmelse)
0.0
devvratvw

See private message.

$68 USD på 1 dag
(1 bedømmelse)
0.0
pradeep4best

See private message.

$42.5 USD på 1 dag
(1 bedømmelse)
0.0
flideravi

See private message.

$4.25 USD på 1 dag
(0 bedømmelser)
0.0
vw1563015vw

See private message.

$63.75 USD på 1 dag
(1 bedømmelse)
2.9
sofcorp

See private message.

$85 USD på 1 dag
(1 bedømmelse)
0.0