Beispiel #1
0
        static void Main(string[] args)
        {
            //chain participants
            var director  = new Director();
            var producer  = new Producer();
            var studioCeo = new StudioCEO();

            //chain hierarchy
            director.SetNetOnCommand(producer);
            producer.SetNetOnCommand(studioCeo);

            //hire some
            var request = new ActorHiringRequest("Daniel", "Craig", 300.000);
            var isHired = director.GetApproval(request);

            if (isHired)
            {
                Console.WriteLine($"Welcome on our brand new tv show {request.ActorName} {request.ActorSurname}!");
            }
            Console.WriteLine();

            request = new ActorHiringRequest("Matt", "Smith", 100.000);
            isHired = director.GetApproval(request);
            if (isHired)
            {
                Console.WriteLine($"Welcome on our brand new tv show {request.ActorName} {request.ActorSurname}!");
            }
            Console.WriteLine();

            request = new ActorHiringRequest("Úrsula", "Corberó", 20.000);
            isHired = director.GetApproval(request);
            if (isHired)
            {
                Console.WriteLine($"Welcome on our brand new tv show {request.ActorName} {request.ActorSurname}!");
            }
            Console.WriteLine();

            request = new ActorHiringRequest("Kostas", "Gouzgkounis", 10.000);
            isHired = director.GetApproval(request);
            if (isHired)
            {
                Console.WriteLine($"Welcome on our brand new tv show {request.ActorName} {request.ActorSurname}!");
            }

            Console.Read();
        }
Beispiel #2
0
        public override bool GetApproval(ActorHiringRequest request)
        {
            if (request.ActorSalary <= 100.000)
            {
                Console.WriteLine(
                    $"{this.GetType().Name} approves the hiring of the well known actor {request.ActorName} {request.ActorSurname}");
                return(true);
            }

            if (NextOnCommand != null)
            {
                Console.WriteLine(
                    $"{this.GetType().Name} cannot approve such a salary will ask for the approve of {NextOnCommand.GetType().Name}");
                return(NextOnCommand.GetApproval(request));
            }

            Console.WriteLine(
                $"As the highest authority {this.GetType().Name} does not approve the cocky expensive actor {request.ActorName} {request.ActorSurname}");
            return(false);
        }
Beispiel #3
0
 public abstract bool GetApproval(ActorHiringRequest request);