Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image

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

Step: 1

Heres a class diagram for the system using the Observer pattern StockSystem UserComponent Stock stoc... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems analysis and design

Authors: kenneth e. kendall, julie e. kendall

8th Edition

135094909, 013608916X, 9780135094907, 978-0136089162

More Books

Students also viewed these Programming questions

Question

What are the two building blocks of structured English?

Answered: 1 week ago

Question

2. In what way are fish movements impaired in cold water?

Answered: 1 week ago