示例#1
0
 // The manager runs “void seeDanger()” to handle the danger by
 // gathering information from all supervisors under his management
 // and execute “void contactBoss()” to inform CEO.
 public override void seeDanger(AbstractEmployee source, EmployeeIF bossMan)
 {
     Console.WriteLine("Manager " + this.name + " becomes aware of danger, gathering information from subordinate supervisors.");
     gatherInformation();
     // and execute “void contactBoss()” to inform CEO.
     contactBoss();
 }
示例#2
0
 // When a regular employee identifies a danger,
 // the issue is reported to his/her supervisor or project leader.
 public override void seeDanger(AbstractEmployee source, EmployeeIF bossMan)
 {
     if (this.boss != null)
     {
         Console.WriteLine("Regular Employee sees danger, reporting to their boss " + this.boss.getName() + ".\n");
         bossMan.seeDanger(this, this.boss);
     }
 }
示例#3
0
        // The supervisor or leader will announce the danger
        // to his/her direct subordinates and also report it to his/her manager.

        // Supervisor Jeff always sends Rob and Rick to support the other team
        // that encounters an incidence, i.e., these two guys perform fixIt()
        // for the other team.
        public override void seeDanger(AbstractEmployee source, EmployeeIF bossMan)
        {
            Console.WriteLine("Superviser " + this.name + " becomes aware of danger, telling all subordinates to fix it. ");
            foreach (RegularEmployee subordinate in subordinateList)
            {
                subordinate.fixIt();
            }
            notify();
            Console.WriteLine("\nSuperviser " + this.name + " informing boss " + this.boss.getName() + " of the danger.");
            boss.seeDanger(this, boss);
        }
示例#4
0
 // Check if employee has subordinate
 public bool hasSubordinate(AbstractEmployee e)
 {
     if (e.subordinateList.Count == 0)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
示例#5
0
 public void evalEmployee(AbstractEmployee employee)
 {
     // Employee has no subordinates, evacuate.
     if (!hasSubordinate(employee))
     {
         employee.evacuate();
         return;
     }
     // Employee has subordinates, for each subordinate
     else
     {
         foreach (AbstractEmployee e in employee.subordinateList)
         {
             // Evaluate for subordinates
             evalEmployee(e);
         }
         employee.evacuate();
     }
 }
示例#6
0
        public override void seeDanger(AbstractEmployee source, EmployeeIF boss)
        {
            //  The CEO receives one decision from each manager.
            Console.WriteLine("Collecting the managers decisions: ");
            foreach (Manager manager in this.subordinateList)
            {
                Console.WriteLine("Adding manager " + manager.name + " decision: [" + manager.decision.decisionMade + "] to the decision list.");
                decisionList.Add(manager.suggestedDecision());
            }

            finalDecision = grant(decisionList);
            Console.WriteLine("The CEO's final decision is: [" + finalDecision.decisionMade + "]");

            // The evacuation is broadcasted from CEO to all employees and the
            // evacuation procedure must start with regular employees first,
            // then supervisors and leaders, managers next, and finally the CEO.
            // Basically, a person’s evacuate() method is called to evacuate and
            // the method displays “The employee [name] is evacuating”.
            finalDecision.doIt(this);
        }
示例#7
0
 public abstract override void seeDanger(AbstractEmployee source, EmployeeIF boss);
示例#8
0
 // The supervisor or leader will announce the danger
 // to his/her direct subordinates and also report it to his/her manager.
 public override void seeDanger(AbstractEmployee source, EmployeeIF bossMan)
 {
     Console.WriteLine("Project Leader becomes aware of danger, notifying their boss");
     boss.seeDanger(this, boss);
 }