嘿,我需要使用一個Int方法Main中的方法ValidateAns中的一個叫做點的方法。我搜索周圍的網和人說我應該做的ValidateAns(點),但它不爲我工作,林不知道如果我做錯了,或者我應該使用一些其他的方式來做到這一點在另一種方法中使用int
static void Main(string[] args)
{
const int QuestionNumbers = 10;
char[] Answear = new char[QuestionNumbers];
Question[] MCQ = new Question[QuestionNumbers];
MCQ[0] = new Question(Slaughterhouse);
MCQ[1] = new Question(Frankenstein);
MCQ[2] = new Question(Things);
MCQ[3] = new Question(Jane);
MCQ[4] = new Question(Kill);
MCQ[5] = new Question(Beloved);
MCQ[6] = new Question(Gatsby);
MCQ[7] = new Question(Catcher);
MCQ[8] = new Question(Pride);
MCQ[9] = new Question(Nineteen);
for (int i = 0; i < QuestionNumbers; i++)
{
Console.WriteLine("Question {0}", i + 1);
Answear[i] = MCQ[i]();
ValidateAns(i + 1, Answear[i]);
Console.WriteLine();
Console.ReadKey();
}
}
static void ValidateAns(int Nbr, char Ans)
{
int points= 0;
switch (Nbr)
{
case 1:
if (Ans == 'b' || Ans == 'B')
{
Console.WriteLine("Good Answear");
points++;
break;
}
else
{
Console.WriteLine("Wrong Answer - The right answer was (B)");
break;
}
}
}
你可以從'ValidateAns'返回'bool'來表示答案是否正確。在循環邏輯中,如果「bool」爲true,則將向點的計數器加1。 – SimpleVar 2014-08-30 14:30:05
我覺得這個問題不應該有標籤[visual-studio-2012]! – 2014-08-30 16:15:48