• 1000 взглянуть и предложить какие-либо изменения, если они необходимы?
public interface IQuestion
{
void AskQuestion();
}
public abstract class Question:IQuestion
{
public string QuestionString { get; set; }
public Question()
{
QuestionString = string.Empty;
}
public Question(string QuestionString)
{
this.QuestionString = QuestionString;
}
public abstract void AskQuestion();
}
public class ChoiceQuestion: Question
{
public List<string> ChoiceList { get; set; }
public ChoiceQuestion(string QuestionString, List<string> Choices)
:base(QuestionString)
{
ChoiceList = Choices;
}
public override void AskQuestion()
{
Console.WriteLine(QuestionString);
foreach(string opt in ChoiceList)
{
Console.Write(opt + "\t");
}
Console.WriteLine("\n=======================================================");
}
}
public class MultipleChoiceQuestion : ChoiceQuestion
{
public List<string> CorrectChoices { get; set; }
public MultipleChoiceQuestion(string QuestionString, List<string> Choices, List<string> CorrectList)
: base(QuestionString, Choices)
{
CorrectChoices = CorrectList;
}
}
public class OptionalChoiceQuestion : ChoiceQuestion
{
public string Answer;
public OptionalChoiceQuestion(string QuestionString, List<string> Choices, string CorrectChoice)
: base(QuestionString, Choices)
{
Answer = CorrectChoice;
}
}
class Program
{
static void Main(string[] args)
{
Question q = new OptionalChoiceQuestion("How many rings are on the Olympic flag?", new List<string> { "None","4","5","7"}, "5");
q.AskQuestion(); // Output to console.
q = new MultipleChoiceQuestion("Which of these are wild animals?", new List<string> { "Tiger", "Dog", "Cat", "Elephant", "Horse" }, new List<string> { "Tiger" , "Elephant" });
q.AskQuestion(); // Output to console.
}
}
Пожалуйста, предоставьте общий c дизайн для того же.