Question: Design system using Observer Pattern.Provide a class Diagram that should include classes Stock System,User A and User B(if necessary introduce new classes and operations.Design should
Design system using Observer Pattern.Provide a class Diagram that should include classes Stock System,User A and User B(if necessary introduce new classes and operations.Design should be easy to add components like User Components should be decoupled and high in cohesion.Provide a pseudo code for the system.In addition for each class provide its attributes/data structures.Make necessary assumptions for the design 
In the system there exists a class StockSystem which keeps track of prices of stocks in the Stock Market. This class supports the following operations: SetPrice(ID,price), ReadPrice(ID), Buy(ID,N), and Sell(ID,N). SetPrice(ID, price) operation set a new price for the stock uniquely identified by ID. ReadPrice(ID) operation returns the current price of the stock identified by ID. Buy(ID, N) operation is used to buy N shares of the stock identified by ID. Sell(ID, N) operation is used to sell N shares of the stock identified by ID. Notice that each stock is uniquely identified by ID. In addition, there exist user components in the system (e.g., UserA, UserB, etc.) that are interested in watching the changes in stock prices, especially, they are interested in watching the out-of-range stock price changes. Specifically, interested users may register with the system to be notified when the price of the stock of interest falls outside of the specified price range. During registration the user needs to provide the boundaries (low, high) for the price range for the specific stock, where, low is the lower stock price and high is the upper stock price of the price range. At any time users may un-register when they are not interested any longer in watching the out-of-range stock price changes of a specific stock. Each time when the price of a stock changes, the system notifies all registered users (for which the new stock price is outside of the specified price range) about the out-of-range stock price change. Notice that if the stock price change is within the specified price range for a given user, this user is not notified about this price change. StockSystem List: User A User B DisplayPrice() DisplayPrice() SetPrice() ReadPrice() Buy() Sell() Note: num represents the number of shares of stock that is uniquely identified by ID.
Step by Step Solution
3.43 Rating (143 Votes )
There are 3 Steps involved in it
heres a design system using the Observer Pattern for the Stock System class along with UserA and UserB classes Classes StockSystem Attributes stocks A ... View full answer
Get step-by-step solutions from verified subject matter experts
