public static void DisplayUserFriendlySols(List <MathSolverLibrary.Equation.Solution> solutions) { if (solutions.Count > 0) { Console.WriteLine(); WriteLineColor(ConsoleColor.DarkYellow, "Solutions:"); } foreach (var sol in solutions) { Console.WriteLine(); string starterStr = ""; if (sol.SolveFor != null) { starterStr += sol.SolveForToTexStr() + " " + sol.ComparisonOpToTexStr() + " "; } string outputStr; if (sol.Result != null) { Console.WriteLine("Result:"); outputStr = starterStr + sol.ResultToTexStr(); outputStr = MathSolver.FinalizeOutput(outputStr); Console.WriteLine(" " + outputStr); if (sol.Multiplicity != 1) { Console.WriteLine(" " + "Multiplicity of " + sol.Multiplicity.ToString() + "."); } } if (sol.GeneralResult != null) { Console.WriteLine("General Result:"); outputStr = starterStr + sol.GeneralToTexStr(); outputStr = MathSolver.FinalizeOutput(outputStr); Console.WriteLine(" " + outputStr); Console.WriteLine(" Where " + sol.GeneralResult.IterVarToTexString() + " is a real integer."); } if (sol.ApproximateResult != null) { Console.WriteLine("Approximate Result:"); outputStr = starterStr + sol.ApproximateToTexStr(); outputStr = MathSolver.FinalizeOutput(outputStr); Console.WriteLine(" " + outputStr); } } Console.WriteLine(); }
public static void UserFriendlyDisplay(MathSolverLibrary.Equation.SolveResult result, MathSolverLibrary.TermType.EvalData evalData) { if (evalData.GetMsgs() != null) { foreach (string msg in evalData.GetMsgs()) { WriteLineColor(ConsoleColor.DarkYellow, " " + msg); } } if (evalData.GetInputTypeStr() != null) { WriteLineColor(ConsoleColor.DarkGreen, "Topic is " + evalData.GetInputTypeStr()); } if (evalData.GetGraphEqStrs() != null) { string finalGraphStr = ""; for (int i = 0; i < evalData.GetGraphEqStrs().Length; ++i) { finalGraphStr += evalData.GetGraphEqStrs()[i]; if (i != evalData.GetGraphEqStrs().Length - 1) { finalGraphStr += "; "; } } WriteLineColor(ConsoleColor.White, "Graph " + finalGraphStr); } if (!result.Success) { WriteLineColor(ConsoleColor.DarkRed, "Failure"); foreach (string msg in evalData.GetFailureMsgs()) { WriteLineColor(ConsoleColor.Red, " " + msg); } } else { if (result.Solutions == null) { return; } int solCount = result.Solutions.Count; if (evalData.GetHasPartialSolutions()) { Console.WriteLine("The input was partially evaluated to..."); for (int i = 0; i < evalData.GetPartialSolutions().Count; ++i) { string partialSolStr = evalData.PartialSolToTexStr(i); partialSolStr = MathSolver.FinalizeOutput(partialSolStr); Console.WriteLine(" " + partialSolStr); } Console.WriteLine(); if (solCount > 0) { string pluralStr = solCount > 1 ? "s were" : " was"; Console.WriteLine("The following " + solCount.ToString() + " solution" + pluralStr + " also obtained..."); DisplayUserFriendlySols(result.Solutions); } } else { Console.WriteLine("The input was successfully evaluated."); if (solCount > 0) { DisplayUserFriendlySols(result.Solutions); } if (result.GetHasRestrictions()) { DisplayUserFreindlyRests(result.Restrictions); } } } }