Homework 4 (C# Interfaces and Collections)

 

Ø Make a stepwise refinement, WinEmployee4.exe Windows App, that manages Employee data. The App is demonstrated without source by Homework4.exe

 

Ø     (40) Make the Employees enumerable

§         Make Employees IEnumerable

§         Instead of an Array, change the internals to use some System.Collection such as ArrayList, and foreach when iterating in the code base.

§         Do this in a new container class Employs. Employs will be much like the “Cars” container class in Troelsen.

§         Employs methods should include

§         public void AddEmployee( Employee emp)

§         public void RemoveEmployee( int EmpID)

§         public int    Count;                           // property, employee count

§         public void ClearAll()

§         public bool Present( Employee emp)  // Exists already?

§         Update the payroll calculations and other methods as needed

Ø     The new “foreach” IEnumerable capability should be demonstrated in the payroll calculation (see below).

 

Ø     (25) Improve the Employee find capability

§         Employs should have a “Find by ID” and “Name Pattern Match” employee lookup capability methods

§         public Employee WithID( int EmpID)                          // ID search

§         public Employee FindName( string NamePattern)   // Regex for Name is preferred

    

Ø     (25) Add a new BonusInfo C# class that has properties that will get and set bonus amounts for all the Employee derived types, and a method to Clear bonus amounts

§        The legal Bonus ranges are:

§         Manager-   2000.00 max

§         Sales-        4000.00 max

§         PT Sales-   1000.00 max

§         HR-              500.00 max

§         Consultant-1000.00 max

Ø     The BonusInfo object basically has 5 entries, one for each Employee derived type. The BonusInfo object is maintained by a single “Bonus” entry Button (and textbox) for each Employee type, and the textbox entry is checked for validity against the values above (and a custom Exception thrown and handled for bad values). A separate “Reset Bonuses” button will clear all BonusInfo entries to zero.

 

Ø     (10) Add a C# Custom Exception “BonusRangeException” to WinEmployee that is used when checking the range of bonus entries, upon bonus entry

§         Use the “BonusRangeException” for all BonusInfo properties

 

Ø     Any bonus calculation will be taken (an exact match to the Homework 4 demo is not required). The BonusInfo data should be used in some way for the bonus.
As an example of a possible new calculation for any Manager’s or Sales Persons’s salary:
    Individual Employee’s salary =  bonus +  base_salary ;

    managers bonus = (bonus from BonusInfo object for all Managers)
    sales bonus =
        (bonus per sale, from BonusInfo object) *
        (sales bonus amount, from SalesPerson Employee object);

NOTE BENE: Future assignments will build on the current Employee App

§        The Employees class will be improved to

§        Have name, ID, and other indexers; and a “++” operator

§        Be written and recovered to a file

§        Be written and recovered to an ADO.NET database

§        Have much more appropriate GUI elements

§        Much more