Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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  image text in transcribed

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

Step: 1

heres a design system using the Observer Pattern for the Stock System class along with UserA and UserB classes Classes StockSystem Attributes stocks A dictionary that stores the stock information Key ... 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

Financial Accounting A Critical Approach

Authors: John Friedlan

4th edition

1259066525, 978-1259066528

More Books

Students also viewed these Programming questions

Question

Trace Greek medical thought from Aesculapius to Hippocrates.

Answered: 1 week ago

Question

Explain all drawbacks of the application procedure.

Answered: 1 week ago

Question

Determine Leading or Lagging Power Factor in Python.

Answered: 1 week ago