private static void EnterGrades(Ibook book) { while (true) { Console.WriteLine("Enter a grade or 'Q' to quit "); var input = Console.ReadLine(); if (input == "q") { break; } try { var grade = double.Parse(input); book.AddGrade(grade); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } catch (FormatException ex) { Console.WriteLine(ex.Message); } finally { Console.WriteLine("**"); } } }
private static bool EnterGrades(Ibook book, bool done) { while (!done) { System.Console.WriteLine("Please enter a grade or 'q' to quit: "); var input = Console.ReadLine(); if (input.ToLower() == "q") { done = true; break; } else { try { double grade = double.Parse(input); book.AddGrade(grade); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } catch (FormatException ex) { Console.WriteLine(ex.Message); } finally { Console.WriteLine(""); } } } return(done); }