Design system using Observer Pattern.Provide a class Diagram that should include classes Stock System,User A and User
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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:<ID,price,num> 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. 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:<ID,price,num> 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.
Expert Answer:
Answer rating: 100% (QA)
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 ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
1.For this activity, you will need to prepare and develop a business plan based on a product/service provided by a business you are familiar with. You will need to access business information for...
-
Discuss how the supply chain for a manufacturing company is influenced by warehouse operations at each step of the manufacturing process.
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Great ride (GR) is in the business of manufacturing and selling high-end vehicles. GR signs a deal with the CEO of a consulting firm for a luxury SUV. You are the long-time Controller for GreatRide...
-
Consider two European call options on the same underlying and with the same maturity, but with different strike prices, K1 and K2 respectively. Suppose that K1 > K2. Prove that the option prices...
-
In what year did Fay Otto create a mobile evidence collection service? O 1986 O 1991 1983 1889
-
What are four common objectives for analyzing a business's financial information?
-
A company that manufactures food and beverages in the vending industry has purchased some handling equipment that cost $75,000 and will be depreciated using MACRS GDS. The class life of the asset is...
-
PROBLEMS 1. The air in a room has a pressure of 100 kPa, a dry-bulb temperature of 22C, and a wet-bulb temperature of 16C. Determine a) The specific humidity, b) The relative humidity, c) The...
-
Trapezoidal rule and or Simpson's 1/3rd rule are commonly used to find the approximate surface area of the agricultural land or some irregular surfaces. In this project you need to design a township...
-
You have been hired by Dynamic Company, Inc. to help them evaluate two projects and help them select the best one. Project A represents an expansion of an existing product line. Project B involves an...
-
Company A can borrow at either an 8.5% fixed rate or a floating rate of prime + 1.75% Company B can borrow at either a floating rate of prime + 1.25% or a fixed rate of 8.65% Company A prefers a...
-
Please provide a citation for each response. 1. Locate an article in the S.C. law review (on-line or in the library). Please give a brief summary of the article. 2. Locate a section in AmJur 2d...
-
When building the complete 2nd order model, you need to create interactions between all of the following EXCEPT: qualitative predictors and other qualitative predictors qualitative predictors and...
-
Research one of the following U.S. government agencies or its counterpart in a nation or union of nations other than the U.S. Department of Justice (DOJ) Department of Transportation (DOT)...
-
Your presentation of the case Lochner v New York was very well put together and was easy to understand with the supportive information. The Supreme Court's decision in the Bakeshop Act was ethical...
-
Assess the main motivations for engagement in sustainable business practices. Develop a plan to address the political, regulatory, or technology environments that impact organizations' supply chain...
-
A non-charmed baryon has strangeness S = 2 and electric charge Q = 0. What are the possible values of its isospin I and of its third component I z ? What is it usually called if I = 1/2?
-
Calculate MHR's inventory turnover ratio and the number of days inventory on hand for 2011 and 2010. (The amount of inventory sold in 2011 and 2010 isn't in the income statement-you have to look in...
-
Complete the table below by indicating whether the transactions or economic events would increase, decrease, or have no effect on the financial ratios in the period they occur. Assume the entity uses...
-
Consider the following entities. Identify the stakeholders in each of the entities. What types of decisions would each of these stakeholders want to make? a. A local, privately owned convenience...
-
Modify the spread sheet to handle development costs.
-
What is a What if analysis?
-
You developed an overhead budget for a construction company. Historically, the companys construction costs are 89% of revenues. What volume of work does the construction company need to achieve in...
Study smarter with the SolutionInn App