【发布时间】:2018-05-24 09:42:07
【问题描述】:
public class NameGuessingGame {
public static void main(String [] Args) {
String[] BarackObama= {
"He's A Famous American",
"He Lives in the whitehouse",
"He has two kids",
"He's name means one is blessed",
"He's Fifty Six Years Old",
};
String[] AmirKhan= {
"He's a famous boxer",
"He Lives in Bolton",
"He's Currently in im a celeb",
"He has two daughters",
"He won a silver award in Two Thousand and Four",
};
String[] Tomcruise= {
"He's age is Fifty Five",
"Started A film Career",
"He's the highest paid actor Hollywood",
"His first film was endless love",
"Has one three golden globe awards"
};
String[] ImranKhan= {
"He's age is Sixty Five",
"Khan retired from cricket in ninety ninety Two",
"In Ninety Ninety six he joined policitics",
"Started playing cricket at the age of 13",
"His Networth is fifety million"
};
String[] CristianoRonaldo= {
"He's age is thirty two",
"He has four children",
"He joined football at the age of sixteen",
"Signed a five-year thirty one million contract",
" He was born in portugal"
};
}
}
Public Static Void GuessMethod(String[] Guess)
这里的问题是,伙计们将如何访问此 GuessMethid 中的数组中的数据。一次使用诸如一个语句之类的索引?我是否有诸如String[]BarackObama [0] = J.Option.Dialogbox 之类的东西来读取用户的输入,因为我将允许用户从语句中猜出正确的答案。任何帮助都将是完美的谢谢你
编辑—— 大家好,我想做什么,是在对话框中一一使用数组中的语句,然后读入用户的输入,例如答案将是巴拉克奥巴马,然后对话框会告诉我答案是否是否正确我知道如何使用 j 选项窗格和对话框。这只是我如何在这个猜测谁方法中实现这些数组的问题。我之前使用过数组和方法,但没有引用了解如何在方法中使用数组谢谢...
【问题讨论】:
-
问题肯定需要改写。目前尚不清楚您在搜索什么、尝试了什么以及预期的结果是什么
-
数据需要重构。此外,您的问题出在哪里仍然有点不清楚:我知道您想做一个猜谜游戏,但我不确定您的确切问题是什么。此外,还有一个主要的算法问题需要您自己解决,并且可能需要重新思考。
标签: java arrays string methods syntax