I was going through this question Chain of responsibility lambda and tried to implement @gontard's solution where he used lambdas to implement Chain of responsibility. Unfortunately when I run the example, I get the following results.
Manager will approve $1000.0
President will approve $8000.0
Your request for $30000.0 needs a board meeting!
Your request for $100000.0 needs a board meeting!
The expected result should be this from the impl:
chain.handle(new PurchaseRequest(1000)); // manager
chain.handle(new PurchaseRequest(8000)); // director
chain.handle(new PurchaseRequest(30000)); // president
chain.handle(new PurchaseRequest(100000)); // board
The successor that implements the 'President' request type seems to replace 'Director's' request type.If anyone is willing to implement the same example and share if the results are the same.thanks
Aucun commentaire:
Enregistrer un commentaire