Ejemplo n.º 1
0
 public void Update(object sender, StockEventArgs eventArgs)
 {
     Console.WriteLine(
         eventArgs.Euro > 40
             ? $"Bank {this.Name} sells euros; Euro rate:{eventArgs.Euro}"
             : $"Bank {this.Name} is buying euros; Euro rate: {eventArgs.Euro}");
 }
Ejemplo n.º 2
0
 public void Update(object sender, StockEventArgs eventArgs)
 {
     Console.WriteLine(
         eventArgs.USD > 30
             ? $"Broker {this.Name} sells dollars; Dollar rate: {eventArgs.USD}"
             : $"Broker {this.Name} buys dollars; Dollar rate: {eventArgs.USD}");
 }
Ejemplo n.º 3
0
        public void Update(object sender, StockEventArgs e)
        {
            StockInfo stockInfo = e.Info;

            Console.WriteLine(
                stockInfo.USD > 30
                    ? $"Broker {this.Name} sells dollars; Dollar rate: {stockInfo.USD}"
                    : $"Broker {this.Name} buys dollars; Dollar rate: {stockInfo.USD}");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Update StockInfo.
        /// </summary>
        /// <param name="sender">
        /// Event sender.
        /// </param>
        /// <param name="e">
        /// StockEventArgs object.
        /// </param>
        public void Update(object sender, StockEventArgs e)
        {
            StockInfo stockInfo = e.StockInfo;

            Console.WriteLine(
                stockInfo.Euro > 40
                    ? $"Bank {this.Name} sells euros; Euro rate:{stockInfo.Euro}"
                    : $"Bank {this.Name} is buying euros; Euro rate: {stockInfo.Euro}");
        }
        private StockEventArgs GetNewCurrency()
        {
            Random         random      = new Random();
            StockEventArgs newCurrency = new StockEventArgs()
            {
                Euro = random.Next(2, 3),
                USD  = random.Next(1, 5),
            };

            return(newCurrency);
        }
 public void Market()
 {
     for (int i = 0; i < measurePeriodSeconds / intervaMeasurelSeconds; i++)
     {
         Console.WriteLine($"\nNew currency data...\n");
         StockEventArgs newData = GetNewCurrency();
         OnCurrencyChanged(this, newData);
         Console.WriteLine(new string('-', 70));
         Thread.Sleep(intervaMeasurelSeconds * 1000);
     }
 }
Ejemplo n.º 7
0
        void Run()
        {
            Random rnd = new Random();

            for (int days = 0; days < 5; days++)
            {
                StockEventArgs stocksInfo = new StockEventArgs();
                stocksInfo.USD  = rnd.Next(20, 40);
                stocksInfo.Euro = rnd.Next(30, 50);
                OnNewStockData(this, stocksInfo);
                Thread.Sleep(2000);
            }
        }
Ejemplo n.º 8
0
 protected void OnMarket(object sender, StockEventArgs e)
 {
     StockEvent?.Invoke(sender, e);
 }
Ejemplo n.º 9
0
 public Stock()
 {
     stocksInfo = new StockEventArgs();
 }
Ejemplo n.º 10
0
 private void Message(object sender, StockEventArgs eventArgs)
 {
     currentCurrency = eventArgs ?? throw new ArgumentNullException($"Incorrect data of {nameof(eventArgs)}");
     Console.WriteLine("Bank report message:");
     Console.WriteLine("Usd = {0}, Euro = {1}\n", eventArgs.USD, eventArgs.Euro);
 }
Ejemplo n.º 11
0
 protected virtual void OnNewStockData(object sender, StockEventArgs e)
 {
     StockData?.Invoke(this, e);
 }
Ejemplo n.º 12
0
 protected virtual void OnCurrencyChanged(object sender, StockEventArgs e)
 {
     CurrencyChanged?.Invoke(this, e);
 }
Ejemplo n.º 13
0
 public Stock(int measurePeriodSeconds, int intervalSeconds)
 {
     currentCurrency             = new StockEventArgs();
     this.intervaMeasurelSeconds = intervalSeconds;
     this.measurePeriodSeconds   = measurePeriodSeconds;
 }
Ejemplo n.º 14
0
 protected virtual void OnStartTimer(StockEventArgs e)
 {
     StockEvent?.Invoke(this, e);
 }
Ejemplo n.º 15
0
 protected virtual void OnNewInfo(object sender, StockEventArgs e)
 {
     NewInfo?.Invoke(this, e);
 }