public override string ToString() { string feedbackMessage = ""; //if the script is null the message should be how many fewer //otherwise cut and paste from NFAED feedback to prompt some message on what to do if (stateDiff > 0 || transitionDiff > 0) { // this feedbackMessage = string.Format("There exists an equivalent NFA with ", transitionDiff); } if (stateDiff > 0) { feedbackMessage += string.Format("{0} fewer states", stateDiff); } if (transitionDiff > 0) { if (stateDiff > 0) { feedbackMessage += " and "; } feedbackMessage += string.Format("{0} fewer transitions.", transitionDiff); } if (feedbackMessage != null && level == FeedbackLevel.Minimal) { return("There exists an equivalent NFA that is smaller."); } if (script != null) { feedbackMessage += " " + script.ToString(); } return(feedbackMessage); }
public override string ToString() { string feedbackMessage = "";//string.Format("U: {0}%. ", utility); switch (level) { case FeedbackLevel.Hint: case FeedbackLevel.SmallHint: { int statesToggleCount = 0; int statesAddCount = 0; int editMoveCount = 0; Dictionary <int, int> transitions = new Dictionary <int, int>(); foreach (var edit in script.script) { if (edit is NFAAddState) { statesAddCount++; } else if (edit is NFAEditState) { statesToggleCount++; } else { editMoveCount++; var cedit = edit as NFAEditMove; if (!transitions.ContainsKey(cedit.sourceState)) { transitions[cedit.sourceState] = 0; } transitions[cedit.sourceState]++; } } if (statesAddCount > 0) { feedbackMessage += string.Format("Your solution does not contain enough states; "); } if (statesToggleCount > 0) { if (statesToggleCount == 1) { feedbackMessage += string.Format("You need to change the acceptance condition of one state; "); } else { feedbackMessage += string.Format("You need to change the set of final states; "); } } if (editMoveCount > 0) { foreach (var key in transitions.Keys) { feedbackMessage += string.Format("Check the transitions out of state {0}; ", key); } } feedbackMessage += "<br /> The following counterexample might help you: "; feedbackMessage += counterexample == "" ? "the empty string" : string.Format("<i>{0}</i>", counterexample); break; } case FeedbackLevel.Minimal: feedbackMessage += string.Format("Your solutions needs {0} {1}.", script.script.Count, (script.script.Count == 1 ? "edit" : "edits")); break; case FeedbackLevel.Solution: feedbackMessage += script.ToString(); break; default: throw new PDLException(string.Format("Undefined level {0}", level)); } return(feedbackMessage); }