Question about using Array!
1 posts in topic
Flat View  Flat View

Posted By:   Patrick_Tang
Posted On:   Sunday, May 25, 2003 06:32 AM

I'm working on a java game, i needs some questions. I think I could use array. here's some code:

Question[] question = Question[15];

question[0]=new Question("Who is Michael Jordan?", "A:Basketball Player", "B:Soccer Player");
...and so on

Is it correct way to use array to store some questions and how to retieve them randomly?

Re: Question about using Array!

Posted By:   Jeanne_Boyarsky  
Posted On:   Sunday, May 25, 2003 09:21 AM

Almost, it should be
Question[] question = new Question[15];

You can use the Math.random() function to generate a random number and multiply it by 15 to get an array index.
About | Sitemap | Contact