In: Computer Science
Consider the online auction site described in Problem 2.31 (Chapter 2, Page no 165). Suppose you want to employ the Publish-Subscribe (also known as Observer) design pattern in your design solution for Problem 2.31. Which classes should implement the Publisher interface? Which classes should implement the Subscriber interface? Explain your answer. (Note: You can introduce new classes or additional methods on the existing classes if you feel it necessary for solution.).
Answer : Given data
* In an auction system there are many things to keep in mind .
* Auction Handler
* Bidder ( It has 2 types they are Random and Constant
Bidder)
* Hence , see the code given below will be implemented by the
Subsciber class because it will consists of all the
properties
or attributes required for te running of the class with possible
multiple inheritence and interface handling in the program .
* AuctionHandler.java
public AuctionHandler(CharSequence bidId,
ConcurrentMap<Long, ConcurrentMap<CharSequence,
BidResponse>> bids) {
if (bidId == null) {
throw new NullPointerException("Id is null");
}
if (bids == null) {
throw new NullPointerException("Id is null");
}
this.bidId = bidId;
this.bids = bids;
}
Hence, this is the reason why the interfaces are used in the
program to increase the readability,
scalability and integrity techniques in the program.
____________THE END_______________