Middle East Technical University Fall ‘98
Department of Computer Engineering
CENG 242
Homework #4

 

REGULATIONS

Due Date: 30 April 1999, Friday (Not subject to postpone)

Environment: You will do your programming on Unix and use C++ as the programming language.

Submission: Electronically. You will be submitting your program source code through a file, which you will name as hw4.cpp by issuing the following single line at Unix prompt in Ceng domain

submit242 hw4.cpp

Resubmission is allowed (till the last moment of the due date), the last will replace the previous, provided you answer the interactive question positively.

Updates: Use and observe tin for any update, comment and question.

Teaming: There is NO teaming.

Cheating: All parts involved (source(s) and receiver(s)) get zero. You can be sure about that!
 

BACKGROUND INFORMATION

    "Youth & Beauty Center" (Genclik ve Guzellik Merkezi) is a very big company that has many departments. At most 4 employees work at each department. Each department has a manager. These managers are also grouped in such a way that, 4 department managers form a unit, and each unit has a director. And there are 4 vice-presidents, each responsible from 4 directors. And all these vice-presidents report to the president of the company.

    In order to be able to understand the hierarchical place of a worker, a hierarchy identifier is assigned to each worker. This identifier is computed as follows:
    "If a one level higher worker in the company (which would be called the parent if you think this organization as a tree) has the hierarchy identifier w, and if the worker whose hierarchy identifier is to be computed is the n'th worker working under this person (corresponds to the n'th child of the parent), then the hierarchy identifier is wn"
For Example:
    Hierarchy identifier of the president is 1.
    Hierarchy identifier of the 2nd vice-president is 12.
    Hierarchy identifier of the 3rd vice-president's 2nd director is 132.

    This identifier is a secret string, and should not be observable to anyone else. The other secret information about the workers are the salary of the worker (in US dollars), experience of the worker (in # of months), and the status of the worker (1 for president, 2 for vice-president, 3 for director, 4 for manager and 5 for employee).

    Sometimes a worker may retire. In that case that worker's information is removed from the organization and another person is selected for the empty title. selection is done as follows:
    "For example, if the president is to be retired then one of the vice-presidents, whose experience is the highest will be the new president (if two or more nominees have the same experience then the one with the lowest hierarchy identifier is selected). But now there is an empty place for a vice-president. Then if the ex-vice president - new president had any directors working under him the one with the highest experience is selected as the new vice-president. And this process goes on as much as it can (Be careful about that each time a retirement occurs a hole will appear in the bottom of that branch, because retirement process is nothing but shifting some workers from bottom to up). Each time a retirement occurs the hierarchy identifiers of the workers whose positions have changed should be re-computed to reflect the current scene of the organization."
 

PROBLEM

    You will implement this organization scheme. You should define a class and each worker should be an object belonging to that class. Data that should be kept private is discussed above. And of course you will need some functions to manipulate these data.

    First you will read the information about the organization scheme from a file named org.dat. Format of this line will be as follows (each on a separate single line):

Name
Hierarchy identifier
Salary
Experience
Name
Hierarchy identifier
...

Here is an example:
Mustafa Gondol
122
3500.00
28
Zombican Balkabak
123
3800.00
67
...

    After you get the organization information you will begin to wait input from the user. Do NOT use any prompt sign, do NOT print on the screen anything other than the things described below: User will enter coded commands. Here is the list of commands, and what you should do as the response:
 

    In order to be able to do the above tasks you will need to overload two operators:

SPECIFICATIONS

Hint: "Youth & Beauty Center" is an aggregate corporation. ("Genclik ve Guzellik Merkezi" cok uluslu bir sirkettir.)

Note: All company and real names in this homework is fictitious.

Good Luck!