Chain of Responsibility: Passing the Buck
Meet Mike the Scalper
Please examine the
scoreTicket(...)
method below to see how Mike the Scalper goes about his work.
If Mike the Scalper has a
If you prefer, you may download and browse the code using an IDE instead:
ticket
in stock for the requested concert, he
- removes it from his inventory
- adds his customary markup fee
- delivers the ticket:
public class Scalper extends TicketHolder { public Ticket scoreTicket(String concert) {
Ticket ticket;
if (inStock(concert))
ticket = removeFromInventory(concert);
else
ticket = connection.scoreTicket(concert);
ticket.markup(20.00);
return ticket;
}
}
(Reading...)
Formatting Hints:
To format... | use this markup: |
---|---|
source code | {source:lang=java|lineNumbers=false}...{source} (Supported languages: java, cpp, csharp, c, python.) |
bold text | __some text__ |
italicized text | ~~some text~~ |
underlined text | @@some text@@ |
a method or class name | ``myMethod(...)`` |