Question: Use observer pattern, Provide class diagram for system to include classes Stock System, User A,User B.Your design should be easy to introduce new types of

Use observer pattern, Provide class diagram for system to include classes Stock System, User A,User B.Your design should be easy to introduce new types of user components (eg user C) interested in observing the changing prices of stocks.Notice the components in your design should be decoupled and high cohesion. a.Provide class diagram b.Provide pseudo code

In the system there exists a class StockSystem which keeps track of

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: SetPrice() ReadPrice() Buy() Sell() User A DisplayPrice() User B DisplayPrice() Note: num represents the number of shares of stock that is uniquely identified by ID. a class Design System using observe pattern. Include diagram for 3 classes Stock system, user A & User B. (if needed include new classes & operations. Provide Psends code

Step by Step Solution

3.44 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a class diagram for the system using the Observer pattern StockSystem UserComponent Stock stoc... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!