static void Main(string[] args) { // initial stock price var initialStockPrice = new StockModel { StockName = "Virtusa Stock Price", CurrentStockPrice = 1000, LastUpdated = DateTime.Now }; // subject to be observed var subject = new StockPrice(initialStockPrice); // attach observers AbstractObserver londonObserver = new LondonStockPriceView(subject); AbstractObserver newYorkObserver = new NewYorkStockPriceView(subject); // change stock price subject.SetState(900); Console.WriteLine(); subject.SetState(1100); Console.WriteLine(); subject.SetState(1200); Console.WriteLine(); Console.ReadKey(); }
public StockPrice(StockModel initalStockState) { CurrentStockState = initalStockState; Observers = new List <AbstractObserver>(); }
public override void Update(StockModel updatedModel) { this.MyStockDisplay = updatedModel; Display(); }
public abstract void Update(StockModel updatedModel);