Question: You have recently learnt about a design pattern called the Observer pattern and that it is possible to create an implementation of the pattern using

You have recently learnt about a design pattern called the Observer pattern and that it is possible to create an implementation of the pattern using events. For this scenario you are required to create an application which contains the following: A class called StockPrice. This class needs to be able to store the name of a stock (stock as in JSE/ DOW Jones / FTSE / NY Stock Exchange) and its price. It should also provide an override of the ToString() which returns the stock's name and price. A class called StockTicker. This class needs to keep track of a list of StockPrices. Whenever a new item is added to the list, an item is removed or a price is updated, the entire stock list must be automatically passed to the following class: o StockDisplay: When created, it should display the entire list of StockPrices to the console window. Every time the list of StockPrices is updated, it should only display the information related to the StockPrice that has changed i.e. not the entire list). The program should continuously loop until the user presses the "e"-key to end the program. At each iteration of the loop the screen should be cleared and a menu displayed to the user. The menu should allow the following options (with associated functionality): o (a)dd a new stock o (update an existing stock o (remove an existing stock (e)nd the program The program should be based on the observer pattern using C# events, which means it should include all of the interfaces and methods required to align to this pattern, while making use of C# events. You have recently learnt about a design pattern called the Observer pattern and that it is possible to create an implementation of the pattern using events. For this scenario you are required to create an application which contains the following: A class called StockPrice. This class needs to be able to store the name of a stock (stock as in JSE/ DOW Jones / FTSE / NY Stock Exchange) and its price. It should also provide an override of the ToString() which returns the stock's name and price. A class called StockTicker. This class needs to keep track of a list of StockPrices. Whenever a new item is added to the list, an item is removed or a price is updated, the entire stock list must be automatically passed to the following class: o StockDisplay: When created, it should display the entire list of StockPrices to the console window. Every time the list of StockPrices is updated, it should only display the information related to the StockPrice that has changed i.e. not the entire list). The program should continuously loop until the user presses the "e"-key to end the program. At each iteration of the loop the screen should be cleared and a menu displayed to the user. The menu should allow the following options (with associated functionality): o (a)dd a new stock o (update an existing stock o (remove an existing stock (e)nd the program The program should be based on the observer pattern using C# events, which means it should include all of the interfaces and methods required to align to this pattern, while making use of C# events
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
