public double CalculateDividendYield(Stock stock) { if (stock.Type == StockType.Common) { return new CommonDividendYieldCalculator(stock.LastDividend, stock.Price).Calculate(); } return new PreferredDividendYieldCalculator(stock.FixedDividend.GetValueOrDefault(), stock.ParValue, stock.Price).Calculate(); }
public double CalculatePeRatio(Stock stock) { return new PeRatioCalculator(stock.Price, stock.LastDividend).Calculate(); }