using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Globalization; namespace LoggingTool.models { class TeamUpQuestionnaire { private double timestamp; private int playerID; List answers = new List(); /* ****************************************************************************** * constructor TeamUpQuestionnaire * @description: creates a TeamUpQuestionnaire object out of the raw input String * ******************************************************************************/ public TeamUpQuestionnaire(String rawInput) { //Split the inputstring on |, the delimiter used in the input format String[] splitInput = rawInput.Split('|'); timestamp = double.Parse(splitInput[0], CultureInfo.InvariantCulture); playerID = int.Parse(splitInput[1]); for (int i = 2; i < splitInput.Count(); i++) { answers.Add(int.Parse(splitInput[i])); } } /* ****************************************************************************** * function toString * @return: String * @description: Returns a string representation of the TeamUpQuestionnaire object * ******************************************************************************/ public String toString() { String res = "Timestamp: +" + timestamp + "\n"; res = res + "PlayerID: + " + playerID + "\n"; for (int i = 0; i < answers.Count; i++) { res = res + "Answer to question " + i + ": " + answers[i] + "\n"; } return res; } /* ****************************************************************************** * function toStringArray * @return: List * @description: Returns a String array containing the information of the TeamUpQuestionnaireObject * ******************************************************************************/ public List toStringArray() { List res = new List(); res.Add(timestamp.ToString()); res.Add(playerID.ToString()); for (int i = 0; i < answers.Count(); i++) { res.Add(answers[i].ToString()); } return res; } } }