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

Inbound 5786132880204621600

Uploaded by

akxiii1321
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)
2 views2 pages

Inbound 5786132880204621600

Uploaded by

akxiii1321
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

North South University

Department of Electrical and Computer Engineering


CSE 215L: Programming Language II Lab

Lab – 9: Inheritance

Objective:
● To understand inheritance and its usage
● To learn to utilize inheritance to ensure reusability of existing code

Task:
1. Implement the following classes:

In main method, create a Faculty object and display name, age, salary and initial. Call
the toString() method of the Faculty object to display all of its information.

2. Implement the following classes:

Person Employee

- name: String - department: String


- age: int - designation: String
- address: String

/* constructor, accessor, mutator */


/* constructor, accessor, mutator */
PartTimeEmployee FullTimeEmployee

- hours: double - basic: double


- rate: double - allowance: double

/* constructor */ /* constructor */
/* accessor-mutator */ /* accessor-mutator */
/* toString */ /* toString */
+ salary(): double + salary(): double

The relationship is as follows:


Employee extends Person
PartTimeEmployee extends Employee
FullTimeEmployee extends Employee

Create an object for PartTimeEmployee and FullTimeEmployee and print their salary.

For FullTimeEmployee, basic is the base salary, i.e. 15000.


Allowance is usually provided as percentage, i.e. 25%.
So the total salary of a full time employee = 15000 + 25% of 15000 = 18750

You might also like