我在这个项目上需要帮助,我正在上课。继承人我得到了什么!
public class Game {
public static void main(String[] args) {
// TODO Auto-generated method stub
int Naruto = 0;
int DragonBallZ = 1;
int Batman = 0;
int Freedom = 0;
int righthand = 1;
int lefthand = 1;
if (Naruto == 0) {
if (lefthand == 0) {
System.out.println("The command 0 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println("You have been given the 'Kunai'");
} else if (righthand == 1) {
System.out.println("The command 1 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println("You have been given the 'Shurikan'");
}
if (DragonBallZ == 1) {
if (lefthand == 0) {
System.out.println("The command 2 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println("You have been given the 'Kaioken' Ability");
} else if (righthand == 1) {
System.out.println("The command 3 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println("You have been given the 'Super Saiyan 4' Ability");
}
if (Batman == 2) {
if (lefthand == 0) {
System.out.println("The command 4 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println(" You have been given the 'Batarang' ");
} else if (righthand == 1) {
System.out.println("The command 5 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println(" You have been given the 'Keen Eyes' Ability");
}
if (Freedom == 3) {
if (lefthand == 0) {
System.out.println("The command 6 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println(" You have been given the 'Rope' ");
} else if (righthand == 1) {
System.out.println("The command 7 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println(" You have been given the 'Knife' ");
}
}
}
}
}
}
}
所以如果有人可以帮助我,我会尝试制作4款游戏,每款游戏都有2种武器。当我运行该程序时,我需要该游戏的1武器。我不断得到该武器号码的所有游戏的结果。所以,如果有人可以提供帮助,那就太棒了!谢谢!
答案 0 :(得分:0)
即使您的问题不明确,我想您希望代码返回
命令1已被使用......
处理...
访问游戏服务器......
成功!
你被赋予'Shurikan'
这不会发生,因为你正在嵌套不同类型的游戏。
从“火影忍者”到“龙珠Z”时,你应该使用else-if
声明。
这是固定代码,希望我理解你的问题。
public class Game {
public static void main(String[] args) {
// TODO Auto-generated method stub
int Naruto = 0;
int DragonBallZ = 1;
int Batman = 0;
int Freedom = 0;
int righthand = 1;
int lefthand = 1;
if (Naruto == 0) {
if (lefthand == 0) {
System.out.println("The command 0 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println("You have been given the 'Kunai'");
} else if (righthand == 1) {
System.out.println("The command 1 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println("You have been given the 'Shurikan'");
}
} else if (DragonBallZ == 1) { //Changed if to else if
if (lefthand == 0) {
System.out.println("The command 2 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println("You have been given the 'Kaioken' Ability");
} else if (righthand == 1) {
System.out.println("The command 3 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println("You have been given the 'Super Saiyan 4' Ability");
}
} else if (Batman == 2) { //Changed if to else if
if (lefthand == 0) {
System.out.println("The command 4 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println(" You have been given the 'Batarang' ");
} else if (righthand == 1) {
System.out.println("The command 5 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println(" You have been given the 'Keen Eyes' Ability");
}
} else if (Freedom == 3) { //Changed if to else if
if (lefthand == 0) {
System.out.println("The command 6 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println(" You have been given the 'Rope' ");
} else if (righthand == 1) {
System.out.println("The command 7 has been used...");
System.out.println("Processing...");
System.out.println("Accessing Game Server...");
System.out.println("Success!");
System.out.println(" You have been given the 'Knife' ");
}
}
}
}
请记住,即使我在回答,这也不是使用本网站的正确方法!