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
-
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...
-
A 14.0-kg bucket is lowered vertically by a rope in which there is 163 N of tension at a given instant. What is the acceleration of the bucket? Is it up or down?
-
A cold front moves through and the temperature drops by 20 degrees. In which temperature scale would this 20 degree change represent the largest change in temperature?
-
Refer to the information in Problem 21-1B. Tohono Companys actual income statement for 2017 follows. Required 1. Prepare a flexible budget performance report for 2017. Analysis Component 2. Analyze...
-
Genuine Spice Inc. began operations on January 1, 2014. The company produces a hand and body lotion in an eight-ounce bottle called Eternal Beauty. The lotion is sold whole-sale in 12-bottle cases...
-
what is meant by the term functionality of a database management system? Explain the responsibility of any two functionalities of a database management system. Discuss how a database transaction is...
-
1. Bare cost and total cost (incl. O&P) of formwork for spread footings (20 pts, specify which lines (or index) in RSMeans data are used) 2. Bare cost and total cost of reinforcement for spread...
-
Suppose that someone owns a 30-year $23000 T-bond with a rate of 4%. After 9 years the bond is sold for cash, but interest rates have fallen to 2.5%. (a) How much has the bond paid in total for the...
-
Discuss your experience. Do you know of local examples of corporate philanthropy/corporate social involvement? Has your company/organization implemented such programs? How successful have they been?...
-
Your stakeholders have asked the project team to recommend a solution to an unanticipated issue in the project. Describe how you plan to lead your group to make the best decision; address the four...
-
If and cos() = = 72 is in the second quadrant, find sin(e)
-
On July 31, Suzie retires from the partnership of Suzie, Brandon, and Trent. The partner capital balances are Suzie, $50,000; Brandon $55,000; and Trent, $18,000. The profit-and-loss-sharing ratio...
-
Last step in calculating the reliability of an entire system: Group of answer choices calculate backup contingency reliabilities calculate notional reliabilities calculate reliabilities of all...
-
Given that i = 0.04 and 22 18.379 23 18.238 24 18.905 Calculate 2P22.
-
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...
-
Mega Tech, Inc. designs and manufactures automotive components. For years, the company enjoyed a stable marketplace, a small but loyal group of customers, and a relatively predictable environment....
-
Describe the features of a project. How do they differ from day-to-day processes within an organization?
-
In 2003, the Department of Health and Human Services in Victoria, Australia, initiated a AU$323 million project to develop HealthSMART, an integrated IT system that would deliver resource management,...
Study smarter with the SolutionInn App