Java 死守创造刽子手游戏

Java 死守创造刽子手游戏,java,substring,Java,Substring,无聊的开场白部分 package Hangman; import java.util.*; public class Hangman { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //Setup Variables String name;

无聊的开场白部分

package Hangman;
import java.util.*;
public class Hangman {

    /**
     * @param args
     */

        public static void main(String[] args) {
        // TODO Auto-generated method stub

        //Setup Variables
        String name;
        int diff, countwrong=0, guesses=0;

        Scanner input = new Scanner (System.in);
我将要用的词

package Hangman;
import java.util.*;
public class Hangman {

    /**
     * @param args
     */

        public static void main(String[] args) {
        // TODO Auto-generated method stub

        //Setup Variables
        String name;
        int diff, countwrong=0, guesses=0;

        Scanner input = new Scanner (System.in);
        //Introduction for the Hangman game.
        System.out.println(" Welcome to Hangman. What is your name?");
        name=input.nextLine();

        System.out.println(" Hello "+name+" You will be playing a Hangman game.");
        System.out.println(" ");

        //Give instructions.
        System.out.println(" This game will have basics Hangman rules.");
        System.out.println(" There will be a certain number of blanks on the screen, resembling the letters of a particular word.");
        System.out.println(" You will have to try and determine the word by guessing letters used in the word.");
        System.out.println(" You will be allotted  7 mistakes to find the word");
        System.out.println(" ");
        System.out.println(" There will be 3 difficulties you can choose form and it will get progressively harder as you go higher.");
        System.out.println(" 1 being words with 5 letters, 2 being words with 7 letters, and 3 being words with 9 letters.");
        System.out.println(" ");

        //Ask user which difficulty they would like to play on.
        System.out.println(" Which difficulty do you want? (1-3)");
        diff=input.nextInt();
我只想用我上面得到的a的索引替换一个零件,但我不知道如何替换

package Hangman;
import java.util.*;
public class Hangman {

    /**
     * @param args
     */

        public static void main(String[] args) {
        // TODO Auto-generated method stub

        //Setup Variables
        String name;
        int diff, countwrong=0, guesses=0;

        Scanner input = new Scanner (System.in);
            **//Check if the letter is in the word.

            //If it is.
            if (a == guessword.substring(i,i+1)){
             System.out.println("This letter is in the "+guessword.indexOf(a)+"th place.");
             temp[i] = temp[i].replace("_", a);
            }

            //If it isn't.
            else {

                //Increase the wrong count by one.
                countwrong++;
            }
无聊的奥特罗

package Hangman;
import java.util.*;
public class Hangman {

    /**
     * @param args
     */

        public static void main(String[] args) {
        // TODO Auto-generated method stub

        //Setup Variables
        String name;
        int diff, countwrong=0, guesses=0;

        Scanner input = new Scanner (System.in);
            //Print the modified array.
            System.out.print(temp[i]+"  ");

        }**

        //Increase number of guesses by one.
        guesses++;

        }
还有一个:-

package Hangman;
import java.util.*;
public class Hangman {

    /**
     * @param args
     */

        public static void main(String[] args) {
        // TODO Auto-generated method stub

        //Setup Variables
        String name;
        int diff, countwrong=0, guesses=0;

        Scanner input = new Scanner (System.in);
使用
String#equals
比较
字符串
=
操作符比较对象引用

package Hangman;
import java.util.*;
public class Hangman {

    /**
     * @param args
     */

        public static void main(String[] args) {
        // TODO Auto-generated method stub

        //Setup Variables
        String name;
        int diff, countwrong=0, guesses=0;

        Scanner input = new Scanner (System.in);
            //If the user guessed correctly.
        if (gameword[n] == temp[n]){
            System.out.println(" You have guessed the word correctly! Congratulations!");
        }

        //If the user could not guess the word.
        else if (countwrong == 6){
            System.out.println(" Sorry. You have not guessed the word.");
            System.out.println(" The word was "+guessword+" .");
        }

            //Output the number of guesses the user took and how many times they got one wrong.
            System.out.println(" You took "+guesses+" guesses to get it right.");
            System.out.println(" You got a incorrect letter "+countwrong+" times.");        
    }

}
应该是

package Hangman;
import java.util.*;
public class Hangman {

    /**
     * @param args
     */

        public static void main(String[] args) {
        // TODO Auto-generated method stub

        //Setup Variables
        String name;
        int diff, countwrong=0, guesses=0;

        Scanner input = new Scanner (System.in);
if (a == guessword.substring(i,i+1)) {
另外,替换

package Hangman;
import java.util.*;
public class Hangman {

    /**
     * @param args
     */

        public static void main(String[] args) {
        // TODO Auto-generated method stub

        //Setup Variables
        String name;
        int diff, countwrong=0, guesses=0;

        Scanner input = new Scanner (System.in);
if (a.equals(guessword.substring(i,i+1))){

package Hangman;
import java.util.*;
public class Hangman {

    /**
     * @param args
     */

        public static void main(String[] args) {
        // TODO Auto-generated method stub

        //Setup Variables
        String name;
        int diff, countwrong=0, guesses=0;

        Scanner input = new Scanner (System.in);

考虑添加一段解释来说明问题的细节和当前最具体的问题。此外,请删除所有不必要的代码来显示问题。Nooooooooooooooooooo>代码>= AGAAAAAAAAAAAAI:(可能的副本)