Exemple #1
0
        public void Update(IMyObservable observevable)
        {
            Stock stock = observevable as Stock;

            if (stock.BTCCourse <= this.CourseForBuy)
            {
                if (this.SummForBuy * stock.BTCCourse < this.USD)
                {
                    this.BTC       += this.SummForBuy;
                    this.USD       -= this.SummForBuy * stock.BTCCourse;
                    this.SummForBuy = 0;
                }
            }
            else
            {
                if (stock.BTCCourse >= this.CourseForSell)
                {
                    if (this.BTC > this.SummForSell)
                    {
                        this.USD        += this.SummForSell * stock.BTCCourse;
                        this.BTC        -= this.SummForSell;
                        this.SummForSell = 0;
                    }
                }
            }
        }
 public void StopSubscrive()
 {
     source.RemoveObserver(this);
     source = null;
 }
 public ConcreteObserverB(string name, IMyObservable obs)
 {
     this.Name = name;
     source    = obs;
     source.RegisterObserver(this);
 }