- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是一个完全的Java新手,在过去几天的业余时间里,我一直在做一个小型游戏,很有趣。
我的问题是,当我尝试编译它时,它给了我16条错误,我完全不知道如何解决它,唯一想到的是,也许我的代码顺序不正确。任何帮助表示赞赏,这是我的代码:
/**RULES AND TIPS:
* IF YOU INPUT AN ANSWER THAT IS NOT ONE OF THE CHOICES YOU WILL DIE AND RESTART
* DO NOT LOOK AT THE CODE, IT KILLS THE FUN MY DUDE:/
* SOMETIMES THERE IS MORE THAN ONE CORRECT ANSWER =)
* WEAPONS AND ARMOR WILL AID IN FIGHTING SITUATIONS
********IN PROGRESS RIGHT NOW, WILL ADD THESE ALL SOME DAY********
* ITEM LIST:
* IRON DAGGER +1 STRENGTH
* IRON SWORD +2 STRENGTH
* IRON BROADSWORD +3 STRENGTH
* STEEL DAGGER +2 STRENGTH
* STEEL SWORD +3 STRENGTH
* STEEL BROADSWORD +4 STRENGTH
* MYTHRIL DAGGER +3 STRENGTH
* MYTHRIL SWORD +4 STRENGTH
* MYTHRIL BROADSWORD +5 STRENGTH
*
* CLOAK +1 DODGE
* MAGIC CLOAK +3 DODGE
*/
import java.util.Scanner;
public class Lame
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int answer;
System.out.println("Welcome to Rod's java game");
System.out.println("Have fun!");
System.out.println("*****RULES AND TIPS ARE IN THE FIRST AND ONLY COMMENT*****");
System.out.println("You come to a fork in the road. Which way do you go?");
System.out.println("Enter 1 for left or 2 for right");
answer = input.nextInt();
if (answer == 1)
{
Dead();
}
if (answer == 2)
{
Right();
}
}
public static void Dead()
{
Scanner input = new Scanner(System.in);
System.out.println("Wrong decision, you died. Recompile and try a different path!");
}
public static void Right()
{
int answer1;
Scanner input = new Scanner(System.in);
System.out.println("");
System.out.println("You walk down the right path and come to a peculiar house.");
System.out.println("It's getting dark outside and the sign says beware of wolves.");
System.out.println("Do you stay in the house for the night or sleep under a tree?");
System.out.println("Enter 1 for the house or 2 for the tree");
answer1 = input.nextInt();
if (answer1 == 1)
{
House();
}
if (answer1 == 2)
{
Tree();
}
}
public static void House()
{
int answer2;
Scanner input = new Scanner(System.in);
System.out.println("");
System.out.println("You survived the night and continue your adventure!");
System.out.println("");
System.out.println("Beyond the house there is a man being robbed by a thug");
System.out.println("What do you do?");
System.out.println("Enter 1 to continue walking or 2 to help him");
answer2 = input.nextInt();
if (answer2 == 1)
{
Dead1();
}
if (answer2 == 2)
{
Help();
}
}
public static void Tree()
{
int answer4;
Scanner input = new Scanner(System.in);
System.out.println("");
System.out.println("You survived the night and continue your adventure!");
System.out.println("");
System.out.println("Beyond the house there is a man being robbed by a thug");
System.out.println("What do you do?");
System.out.println("Enter 1 to continue walking or 2 to help him");
answer2 = input.nextInt();
if (answer4 == 1)
{
Dead1();
}
if (answer4 == 2)
{
Help();
}
public static void Dead1()
{
Scanner input = new Scanner(System.in);
System.out.println("As you attempt to continue walking, the thug stops you");
System.out.println("Before you can say anything, he unsheaths his sword and kills you!");
System.out.println("Wrong decision, you died. Recompile and try a different path!");
}
public static void Help()
{
int answer3;
Scanner input = new Scanner(System.in);
System.out.println("");
System.out.println("As you run over to help the man, the thug attacks you!");
System.out.println("You defeat the thug easily, and he drops his Iron Sword!");
System.out.println("****IRON SWORD OBTAINED****");
System.out.println("");
System.out.println("");
System.out.println("You continue your journey.");
System.out.println("After a few hours of walking, you get to a dark castle.");
System.out.println("Your sense of adventure draws you towards the castle");
System.out.println("You enter, and are immediately greeted by a spiral staircase.");
System.out.println("Enter 1 to go up the staircase or 2 to continue walking");
answer3 = input.nextInt();
if (answer3 == 1)
{
Staircase();
}
if (answer3 == 2)
{
Continuewalking();
}
public static void Staircase()
{
Scanner input = new Scanner(System.in);
System.out.println("You die. The end.");
}
public static void Continuewalking()
{
Scanner input = new Scanner(System.in);
System.out.println("You die. The end.");
}
}
}
}
16 errors found: File: C:\Users\Rod\Desktop\java files\Lame.java [line: 116] Error: illegal start of expression File: C:\Users\Rod\Desktop\java files\Lame.java [line: 116] Error: illegal start of expression File: C:\Users\Rod\Desktop\java files\Lame.java [line: 116] Error: ';' expected File: C:\Users\Rod\Desktop\java files\Lame.java [line: 116] Error: ';' expected File: C:\Users\Rod\Desktop\java files\Lame.java [line: 123] Error: illegal start of expression File: C:\Users\Rod\Desktop\java files\Lame.java [line: 123] Error: illegal start of expression File: C:\Users\Rod\Desktop\java files\Lame.java [line: 123] Error: ';' expected File: C:\Users\Rod\Desktop\java files\Lame.java [line: 123] Error: ';' expected File: C:\Users\Rod\Desktop\java files\Lame.java [line: 149] Error: illegal start of expression File: C:\Users\Rod\Desktop\java files\Lame.java [line: 149] Error: illegal start of expression File: C:\Users\Rod\Desktop\java files\Lame.java [line: 149] Error: ';' expected File: C:\Users\Rod\Desktop\java files\Lame.java [line: 149] Error: ';' expected File: C:\Users\Rod\Desktop\java files\Lame.java [line: 154] Error: illegal start of expression File: C:\Users\Rod\Desktop\java files\Lame.java [line: 154] Error: illegal start of expression File: C:\Users\Rod\Desktop\java files\Lame.java [line: 154] Error: ';' expected File: C:\Users\Rod\Desktop\java files\Lame.java [line: 154] Error: ';' expected
最佳答案
您正在尝试定义一个方法(Dead1
),同时仍在另一个方法(main
)中。
它不是那样工作的。从那里开始。
请记住,一致的缩进或多或少消除了这种愚蠢的错误。
关于java - 一点文字游戏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21151184/
由于 typescript 现在支持条件类型,我决定进行一些元编程,为 VSCODE intellisense 添加更多 flavor 。但是,虽然使用 A extends B 可以轻松分离其他类型,
我有一个 php var,它在回显时将 JS 函数写入页面的源代码。该函数循环遍历 CSV,因此其中包含以下行: $str="var lines = data.split('\n');"; 目前,当回
我有以下代码: name= "a"; value="b" $.post("ajax.php", {name:value}).... 然而 ajax.php 将收到 name=b 而不是 a=b。 我如
以下情况: var myVehicle = { brand: 'Tesla' }; var isMoving = Symbol(); var currentStatus = Symbol(); myV
我正在为 Python 翻译器编写 JavaScript,“\8”和“\9”给我带来了很多问题。根据文档,像“\8”或“\9”这样的东西是非法的,因为它们不是有效的八进制转义符。 Esprima pa
我有一个简单的 LinearLayout。当我将 android:background 添加到 LinearLayout 时,TextView 不再可见。 我不明白什么?
在尝试获得某种效果时遇到困难: 我有一张图片。我想将鼠标悬停在它上面。它应该变黑并弹出一些文本。 例子^ 执行此操作最简单/最简单的设置是什么?最好只有 HTML 和 CSS 注意:该元素需要在 CS
考虑以下代码: #include void f(const char * str) { str = "java"; } void main (int argc, char * argv[])
我想在 MySQL 中插入一条具有非 ASCII Unicode 字符的记录,但我在一个不允许我轻松键入非 ASCII 字符的终端上。如何在 MySQL 的 SQL 语法中转义 Unicode 文字?
Perl脚本batchReplace.pl可以用来批量替换文件中的文字/代码。可在指定目录中查找指定类型的文件,并递归检查子目录;在输出文件时复制输入文件的目录结构。 [附件]Win32应用程序b
我知道从 flutter 应用程序共享的官方包。 https://pub.dartlang.org/packages/share 共享文本和 url 很容易,但我想共享来自服务器的图像意味着它是 UR
在 Qt 文档中,它说 qreal是一个 Typedef for double unless Qt is configured with the -qreal float option. 这基本上意味
我想让 idris 证明 testMult : mult 3 3 = 9有人居住。 不幸的是,这是键入为 mult (fromInteger 3) (fromInteger 3) = fromInte
如您所知,Apple 为 NSNumber、NSDictionary、NSArray 等类提供了 @literals,因此我们可以通过这种方式创建对象,例如 NSArray *array = @[ob
有没有办法在类型上定义公共(public)文字(C# 中的公共(public) const)?显然 let 类型中的绑定(bind)必须是私有(private)的,并且 Literal 属性不能应用于
为什么下面的语法不能识别 bool 值? 我已经将其与 Java 和 GraphQL 的语法进行了比较,但不明白为什么它不起作用。 给定以下语法,解析如下: foo = null // foo = v
当我需要一个文字来测试一个带有序列的函数时,我注意到我自己的习惯比列表更频繁地使用向量。 IE。 : (map inc [1 2 3]) 但不是: (map inc (list 1 2 3)) 虽然它
是否可以在sqlite中制作类似的东西? FOREIGN KEY(TypeCode, 'ARawValue', IdServeur) REFERENCES OTHERTABLE(TypeCode, T
在我这学期的系统软件类(class)中,我们正在学习汇编程序和其他系统软件。在阅读整个类(class)时,我遇到了LITERALS主题。 对文字和立即操作数进行了比较,发现它们之间的唯一区别是文字不被
我正在使用命令行语法编写一个 gstreamer 管道来发送视频流,并想用它发送数据。我认为可行的一种解决方案是将数据作为字幕文件发送。 我可以使用以下管道通过 rtp 多路复用视频和字幕文件: gs
我是一名优秀的程序员,十分优秀!