public Messages DisplayMessage(IntakeStastics stats) { Messages message = new Messages( waterIntakeSoFarMessage: string.Concat("You have consumed ", stats.OuncesConsumed, " ounce(s) of water today.") ); { message.WaterIntakeUntilGoalMetMessage = string.Concat("You need to drink ", stats.OuncesRemaining, " more ounce(s) to meet daily goal!"); message.IntakeInExcessOfGoal = string.Concat("You surpassed your goal by ", stats.OuncesInExcessOfGoal, " ounce(s)!"); } return(message); }
private static void PromptForIntake(DateTime signalTime) { aTimer.Enabled = false; string input; do { Console.Beep(); Console.WriteLine("Please enter your water intake in ounces in the last hour: ", signalTime); input = Console.ReadLine(); } while (water.IsValidNumber(input) == false); int intake = Convert.ToInt32(input); Console.WriteLine("You drank {0} ounce(s) in the past hour. \n", intake); water.AddOuncesDrank(intake); // method IntakeStastics stats = water.ComputeStatistics(); total += intake; //TODO: return a single string with the display message Messages message = water.DisplayMessage(stats); if (total < Constants.WaterIntakeGoal) { Console.WriteLine(message.WaterIntakeSoFarMessage); Console.WriteLine(message.WaterIntakeUntilGoalMetMessage); Console.WriteLine(); } if (total >= Constants.WaterIntakeGoal) { Console.WriteLine(message.GoalMetMessage); Console.WriteLine(message.IntakeInExcessOfGoal); aTimer.Enabled = false; SpeechSynthesizer x = new SpeechSynthesizer(); x.Speak("Nicely done. Mission Accomplished."); } aTimer.Enabled = true; }
public IntakeStastics ComputeStatistics() { IntakeStastics x = new IntakeStastics(); int intake = 0; foreach (int oz in ounces) { intake += oz; } x.OuncesConsumed += intake; x.OuncesRemaining -= intake; if (x.OuncesRemaining < 0) { x.OuncesInExcessOfGoal = x.OuncesRemaining * -1; x.OuncesRemaining = 0; } return(x); }