我需要一些帮助才能开始使用Windows Phone 7上的简单测验应用程序。
用户将不得不猜测图中所示城市中给定地点的名称是什么。
屏幕上将出现一幅图片,在它的下方将有4个答案,如果用户单击正确的答案,则将被告知正确的答案,然后他可以转到另一个问题,与不正确的回答情形相同。我需要跟踪正确的答案。因此,我需要有关如何设置此类问答游戏的帮助或指导。我需要所有随机生成的问题(每个问题4个随机答案),并且说每场比赛我将有10个问题。

我正准备有一份清单,该清单可以保存我的城市地点

  cityList = new List<string>();

        cityList.Add("answer1");
        cityList.Add("answer2");
        cityList.Add("asnwer3");
        cityList.Add("answer4");


而且我被困住了,任何在做过类似事情之前的人都请帮忙,谢谢

最佳答案

这样的事情。我在答案框中输入了它,它可能不会按原样编译,但肯定会帮助您入门。

class Question

{
    string ImageURI { get; set; }
    string Text { get; set; }
    ObservableCollection<Answer> Answers { get; set; }
    Answer CorrectAnswer { get; set; }

    bool MakeGuess(Answer a) { UserGuess = a; if (a.Equals(CorrectAnswer)) {  return true; } return false; }

    bool AnsweredSuccessfully { get { return UserGuess != null && UserGuess.Equals(CorrectAnswer); } }
    Answer UserGuess { get; set; }

}

class Answer
{
   string text { get; set; }
}
class Game
{
    public Game()
    {
         Questions = new ObservableCollection<Question>();
         for (int i = 0; i < 10; i++) { Questions.Add(GenerateQuestion()); }
    }
    public Question GenerateQuestion()
    {
       Question q = new Question();
       q.ImageURI = your link to image//;
       q.Text = your image text//;
       q.Answers = new ObservableCollection<Answer>();
       q.CorrectAnswer = the correct answer//;
       q.Answers.Add(CorrectAnswer);

       for (int i = 0; i < 5; i++) { q.Answers.Add(GenerateAnswer(q.CorrectAnswer)); }

       return q;
    }
   public Answer GenerateAnswer(Answer ignore)
{
     List<Answer> answers = DataStore.Answers;//go to your main list of answers.

     Random rand = new Random();

     Answer a = answers[Random.Next(0,answers.Size())];
     while (a == null || a.Equals(ignore) {  a = answers[Random.Next(0,answers.Size())];}
     return a;
}
    public ObservableCollection<Question> Questions { get; set; }
}

07-28 04:02