forked from kyordhel/GPSRCmdGen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PredefindedQuestion.cs
108 lines (91 loc) · 3.18 KB
/
PredefindedQuestion.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.ComponentModel;
using System.Xml.Serialization;
namespace GPSRCmdGen
{
/// <summary>
/// Represents a Question from the set of Predefined Questions
/// according to the RoboCup@Home Rulebook 2015
/// </summary>
[Serializable]
public class PredefindedQuestion : INameable, ITiered, IMetadatable
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="GPSRCmdGen.PredefindedQuestion"/> class.
/// </summary>
/// <remarks>Intended for serialization purposes</remarks>
public PredefindedQuestion() : this("tell your name", "[varies]", DifficultyDegree.Easy) { }
/// <summary>
/// Initializes a new instance of the <see cref="GPSRCmdGen.PredefindedQuestion"/> class.
/// </summary>
/// <param name="question">The question for which there is no an unique answer</param>
public PredefindedQuestion(string question) : this(question, "[varies]", DifficultyDegree.Easy) { }
/// <summary>
/// Initializes a new instance of the <see cref="GPSRCmdGen.PredefindedQuestion"/> class.
/// </summary>
/// <param name="question">The question</param>
/// <param name="answer">The answer for the question</param>
public PredefindedQuestion(string question, string answer) : this(question, answer, DifficultyDegree.Easy) { }
/// <summary>
/// Initializes a new instance of the <see cref="GPSRCmdGen.PredefindedQuestion"/> class.
/// </summary>
/// <param name="question">The question</param>
/// <param name="answer">The answer for the question</param>
/// <param name="tier">The difficulty degree (tier) for UNDERSTANDING the question</param>
public PredefindedQuestion(string question, string answer, DifficultyDegree tier)
{
this.Question = question;
this.Answer = answer;
this.Tier = tier;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the question string
/// </summary>
[XmlElement("q")]
public string Question { get; set; }
/// <summary>
/// Returns the <c>"question"</c> string
/// </summary>
[XmlIgnore]
string INameable.Name { get { return "question"; } }
/// <summary>
/// Returns a set of two strings, the firs containing the question,
/// and the second one containing the answer
/// </summary>
[XmlIgnore]
string[] IMetadatable.Metadata
{
get
{
return new String[]{
String.Format("Q: {0}", this.Question),
String.Format("A: {0}", this.Answer)
};
}
}
/// <summary>
/// Gets or sets the answer string
/// </summary>
[XmlElement("a")]
public string Answer { get; set; }
/// <summary>
/// Gets or sets the difficulty degree (tier) for UNDERSTANDING the question
/// </summary>
[XmlAttribute("difficulty"), DefaultValue(DifficultyDegree.Easy)]
public DifficultyDegree Tier{ get; set; }
#endregion
#region Methods
/// <summary>
/// Returns a <see cref="System.String"/> that represents the current <see cref="GPSRCmdGen.PredefindedQuestion"/>.
/// </summary>
/// <returns>A <see cref="System.String"/> that represents the current <see cref="GPSRCmdGen.PredefindedQuestion"/>.</returns>
public override string ToString()
{
return String.Format("{0} ({1})", this.Question, this.Tier);
}
#endregion
}
}