2017-12-10 17 views
-1
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。一度に1つのステートメントなどのインデックスを使用するString[]BarackObama [0] = J.Option.Dialogboxユーザーからの入力を読み取るために、ユーザーが文から正しい答えを推測できるようにします。すべてのヘルプは完璧ですありがとうございますJava名推測ゲーム - 配列文字列にアクセスする方法

EDIT --- こんにちはみんな私は何をしようとしています、ダイアログボックスの配列のステートメントを1つずつ使用してから、ユーザーからの入力を読み込みます答えの例がBarack Obamaになり、答えが正しいかどうかダイアログが私に教えてくれます。私はJオプションペインとダイアログボックスを使う方法を知っています。どのように私はこの推測でこれらの配列を実装するのかという問題だけです。私は

+0

質問は間違い言い換え必要ループを使用して...メソッドの前にしても、配列を使用しているが、この方法のおかげで配列を使用する方法を理解引用していません。何を探しているのか、何を試したのか、期待される結果は何かが明確ではない – pinturic

+0

データを再構成する必要があります。また、あなたの問題がどこにあるかはまだ少しはっきりしていません。推測ゲームをしたいと思っていますが、あなたの正確な問題が何であるか分かりません。また、あなた自身で解決する必要のある主要なアルゴリズム上の問題があり、おそらく考え直す必要があります。 – ionizer

答えて

0

for(String question : BarackObama){ 
    // question will be "He's A Famous American" in first iteration, 
    //"He Lives in the whitehouse" in second iteration ans so on. 
    //you can get display question and get input from the user here 

} 
関連する問題