This is my code on Q&A game on Visual C++
if (this->answer->Text == "2"){
this->question->Text = "2+2?";
}
else if (this->answer->Text == "4"){
this->question->Text = "3+3?";
}
else if (this->answer->Text == "6"){
this->question->Text = "4+4?";
}
else if (this->answer->Text == "8"){
this->question->Text = "Finished!";
}
else {
MessageBox::Show("Wrong!!");
}
Is there any to shorten this code? consider using arrays?
I am not a Windows programmer, don’t know what the type of your
this->question->Textis, you didn’t tell us, but if it isstd::stringor something which can be converted tochar *, then this should work: