public static void Main(string[] args) { var fizzBuzzService = new FizzBuzzCalculator(); for (int i = 1; i <= 1000; i++) { var replacementText = fizzBuzzService.GetValue(i); Console.WriteLine(replacementText); } Console.ReadLine(); }
static void Main(string[] args) { //setup app IFizzBuzzCalculator calculator = new FizzBuzzCalculator(); IOutput output = new Outputter(Console.Out); var app = new FizzBuzzProcessor(calculator, output); //process collection app.ProcessCollection(Enumerable.Range(MinValue, MaxValue)); //hold screen Console.ReadLine(); }
public List <string> CalculateResultsForNIterations(int numberOfIterations) { CheckIterationIsInRange(numberOfIterations); var resultList = new List <string>(numberOfIterations); var calculator = new FizzBuzzCalculator(); for (int iterator = 1; iterator <= numberOfIterations; iterator++) { resultList.Add(calculator.CalculateCurrentValue(iterator)); } return(resultList); }
static void Main(string[] args) { int _lowerNumber, _higherNumber; var mappings = new Dictionary<Tuple<bool, bool>, string> { { new Tuple<bool, bool>(true, true), "- FizzBuzz"}, { new Tuple<bool, bool>(true, false), "- Fizz"}, { new Tuple<bool, bool>(false, true), "- Buzz"}, { new Tuple<bool, bool>(false, false), " - N/A"} }; try { Console.WriteLine("Enter a lower number: "); string LowerNumber = Console.ReadLine(); if (int.TryParse(LowerNumber, out _lowerNumber)) { //Console.WriteLine("Thank you for entering: {0}", _lowerNumber): } else { Console.WriteLine("Invalid input: {0}", LowerNumber); } Console.WriteLine("Enter a higher number: "); string HigherNumber = Console.ReadLine(); if (int.TryParse(HigherNumber, out _higherNumber)) { //Console.WriteLine("Thank you for entering: {0}", _higherNumber); } else { Console.WriteLine("Invalid input: {0}", HigherNumber); } if (_lowerNumber > _higherNumber) { Console.WriteLine("Invalid Data. Higher number should be > than lower number"); } else { var fizzBuzz = new FizzBuzzCalculator(mappings, (n) => n % _lowerNumber == 0, (n) => n % _higherNumber == 0); for (int i = 0; i < 200; i++) { Console.WriteLine(fizzBuzz.NumberFormat(i)); } Console.ReadLine(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }