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

LabInheritance PDF

This document describes an inheritance lab assignment for a programming class. Students are tasked with creating a program for a law firm that tracks employee salaries using inheritance. There are three types of employees - programmers, lawyers, and accountants - with their own attributes and salary calculations. The program must set up a class hierarchy with an abstract Employee class and subclasses for each type of employee. Employees will have a name and salary attribute, and subclasses will implement a reportSalary() method to print salary details specific to that type.

Uploaded by

theomega76
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)
88 views2 pages

LabInheritance PDF

This document describes an inheritance lab assignment for a programming class. Students are tasked with creating a program for a law firm that tracks employee salaries using inheritance. There are three types of employees - programmers, lawyers, and accountants - with their own attributes and salary calculations. The program must set up a class hierarchy with an abstract Employee class and subclasses for each type of employee. Employees will have a name and salary attribute, and subclasses will implement a reportSalary() method to print salary details specific to that type.

Uploaded by

theomega76
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

CSCD211 Programming Principles II 1/29/2013

Inheritance Lab
You are a programmer in the IT department of an important law firm. Your job is to create a program
that will report gross salary amounts and other compensation.

There are three types of employees in your firm:


Programmers
Lawyers
Accountants

Your computer-based solution will use inheritance to reflect the general-to-specific nature of your
employee hierarchy.

Common attributes for all employees are:


Name
Salary
Attributes for specific employee types are:
Lawyers:
Stock options earned (type int)
Accountants
Parking allowance amount (type double)
Programmers:
Bus pass (type boolean)
The three specific classes of employees should extend the abstract Employee class (nobody is a generic
employee) and implement their own reportSalary() method.

The pay schedule is:


o Employees earn the base salary of $40K per year
o Accountants earn the base employee salary per year
o Programmers earn the base employee salary plus $20K per year
o Lawyers earn the base employee salary plus $30K per year

Requirements:

o Each subclass of Employee must implement its own reportSalary() method. The specific
implementations of reportSalary() are limited to a printed line:

System.out.println(I am a lawyer. I get + getSalary() + , and I have +


getOptions() + shares of stock.);

Eastern Washington University


CSCD211 Programming Principles II 1/29/2013

System.out.println(I am an accountant. I make + getSalary() + plus a parking


allowance of + getParking());

System.out.println("I am a programmer. I make " + getSalary() + " and I" +


((getBusPass())?" get a bus pass.":" do not get a bus pass."));

o Salaries for specific types of employees are in addition to the base employee salary.
Raising the base employee salary should automatically raise salaries for all types of
employees (hmmm).
o An object of the Employee class cannot be instantiated because it would be too
general.
o Attribute(s) that belong to a super or sub class should be initialized in the corresponding
class constructor.

Task 1:
Setup a class hierarchy to accurately reflect the relationships in your law firm.

Task 2:
Create a driver program that will create employee objects and report salaries for your companys
employee base:

Programmers: (your name goes here) - No bus pass


Will E. Makit - Bus pass

Lawyers: Ivana Killmen - 11 shares signing bonus


Luke N. Dimm - 0 shares signing bonus
Eileen Dover - 100 shares signing bonus

Accountants: Bill Cheatem - Parking allowance $ 17.00


Joe Kisonyou - Parking allowance $ 45.50
Seymore Butts - Parking allowance $ 2.50

Print your code listing and submit on paper, in class. See Canvas for due date.

Eastern Washington University

You might also like