Objectives

The goal of this assignment is to learn the following:

Overview

In this assignment you will create a program that tells the user the different amounts an employee can make, depending on what kind of employee they are. There are three different kinds of employees: a salaried employee, an hourly employee, and a commissioned employee. Each one will require different inputs and will require a different method for calculating earnings.

Requirements

You will need five classes: Employee, SalariedEmployee, HourlyEmployee, CommissionEmployee, and Main. Class Employee will be your base class, and will contain actions and blueprint actions to be used in each class that inherits from Employee.

Class Employee

In this class, you will implement several setters and getters for variables that will be used in each class that inherits from Employee. Since every employee, regardless of how they are paid, share some common information (they have a name and a social security number), this class will obtain and provide that information. Class Employee will have the following actions:

Each class will have a separate implementation for Earnings, so a blueprint action will work well here.

Class SalariedEmployee

This class will inherit from Employee. It needs the following actions:

action Earnings returns number
    return GetWeeklySalary()
end

Since action GetWeeklySalary returns a value, you can call the action in a return statement, as seen above.

Class HourlyEmployee

This class also inherits from Employee. It needs the following actions:

Class CommissionEmployee

This class also inherits from Employee. It needs the following actions:

Class Main

In class Main, create variables that will satisfy all the arguments for each class. Then call the appropriate actions from each class to satisfy the requirements in the Sample Output section.

Sample Output

When run, the program should report to the user the name of the employee, what kind of employee they are, and what their earnings are. For the hourly employee, tell the user what their hourly wage and number of hours worked are, in addition to their name, earnings, and type of employee. For a commissioned employee, tell the user their commission rate and the number of sales they made, in addition to their name, earnings, and type of employee. Output should be similar to the following:

Salaried employee Brandon Spencer. Total earnings for this salaried employee is 60,000 dollars.
Commission employee Brandon Spencer. Gross sales is 20 sales at 4 dollars per a sale. Total earnings for this commissioned employee is 80 dollars.
Hourly employee Brandon Spencer. Hourly wage is 16.0 and number of hours worked is 40. Total earnings for this hourly employee is 640 dollars.

Next Tutorial

In the next tutorial, we will discuss Challenge 6.1, which describes an audio environment for battles using inheritance..