【发布时间】:2017-06-02 00:15:34
【问题描述】:
我正在编码谁想成为百万富翁,我使用了数组,然后是一个循环,每个都相互对应,但是如果我想随机化每个问题并且答案必须对应怎么办。
String[] ques =
{
"Which of these dance names is used to describe a fashionable dot?",
"What is the only position on a football team that can be 'sacked'?",
"What god of love is often depicted as a chubby winged infant with a bow and arrow?",
"Which of the following months has no U.S. ferderal holiday?",
"What mythological beast is reborn from its own ashes?",
"Who developed the first effective vaccine against polio?",
"Which of the following is not a monotheistic religion?",
"In 2014, 17-year-old Pakistani Malla Yousafzai became the youngest person ever awarded the Nobel Peace Prize in recognition of her work for what?",
"Translated from the Latin, what is the motto of the United States?",
"As part of its maintenance, which of these tourist attractions requires the use of embalming fluid?",
"Gerontology is the study of what?",
"The card game solitaire is also called what?",
"Which of the following is the title of an acclaimed PBS science series?",
"When asked why he wanted to climb Mount Everest, what explorer said, 'Because it's there'?",
"According to the well-known phrase, if a plan is not perfect what will be found 'in the ointment'?" };
//Create answers with 2d array
String[][] answ = { { "1.Hora", "2.Swing", "3.Lambada", "4.Polka" },
{ "1.Center", "2.Wide receiver", "3.Tight end", "4.Quarterback" },
{ "1.Zeus", "2.Mercury", "3.Cupid", "4.Poseidon" },
{ "1.August", "2.February", "3.September", "4.November" },
{ "1.Phoenix", "2.Minotaur", "3.Dragon", "4.Golem" },
{ "1.Albert Sabin", "2.Niels Bohr", "3.Louis Pasteur",
"4.Jonas Salk" },
{ "1.Islam", "2.Judaism", "3.Hinduism", "4.Christianity" },
{ "1.Animal welfare", "2.Freedom of the press",
"3.Nuclear disarmament", "4.Education rights" },
{ "1.In God we trust", "2.One out of many", "3.All as one",
"4.Striving together" },
{ "1.Lenin's tomb", "2.Mount Rushmore", "3.Stonehenge",
"4.Hoover Dam" },
{ "1.Music history", "2.Aging", "3.Color", "4.Grammar" },
{ "1.Patience", "2.Rochambo", "3.Concentration",
"4.Associations" },
{ "1.Nova", "2.Pulsar", "3.Universe", "4.Life" },
{ "1.Reinhold Messner", "2.Sir Edmund Hillary",
"3.Peter Habeler", "4.George Mallory" },
{ "1.Salmon", "2.Frog", "3.Fly", "4.Wildebeest" } };
//Correct answers
int[] correctAnswers = { 4, 4, 3, 1, 1, 4, 3, 4, 2, 1, 2, 1, 1, 4, 3 };
【问题讨论】:
-
有人可以给我一个使用我创建的数组的例子吗?