好的,这是我的代码,我知道它很混乱,而且充满了其他错误,我仍在努力学习。我知道我可以在一个班级中做到这一点,但这会脱离 java 的 OOP 部分。我想如果我要学习,我也可以正确地学习。
charHpArray两天来,我一直试图弄清楚如何打印出来,但我在谷歌上找到的所有内容都没有用,因为它们不包含另一个数组。本质上,我试图将它设置为参数级别,因此当level= 1 时hp为 5,何时level为 2 时hp为 10,依此类推。
另外,如果你能告诉我为什么level + #不起作用那会很棒。//如果你也想尝试一下,我正在努力让mage, arch, 和war都有不同的起始奖金,所以war比基本level奖金多一点健康。
** 鼓励所有答案,即使这意味着新想法我只是想学习**
谢谢。
编码:
import java.io.*;
import java.util.Scanner;
import java.util.Random;
public class Main {
public static void main(String[]args) {
Scanner input = new Scanner(System.in);
Random roll = new Random();
System.out.println("Welcome To Adventure Heroes");
System.out.println("-------------------");
System.out.println("You awake to the sound of screaming, \"GET AWAY FROM ME!\"");
System.out.println("You call out to the voice in the distance...");
System.out.println("There is no answer");
System.out.println("You run towards the troubled screams in the distance");
System.out.println("You see a man on the floor being kicked, without hesitation you charge in and push the attacker off the man.");
System.out.println("You examine the man to see if he is okay. When you look up the attacker is gone.");
System.out.println("\"Thank you so much... erm, come to think of it I've never seen you around these parts. What is Your name?\"");
String yourName = input.next();
System.out.println("\"What a weird name, Hi " + yourName + ", I'm Borgan\"");
System.out.print("\"Well " + yourName + ", your journey begins here.\"");
Character.getcharHp() ;
public class Character {
int[] level ={1,2,3,4,5,6,7,8,9,10};
int[] charHpArray = {5,10,15,20,25,30,35,40,45,50};
Character(int[] charHp)
{
charHp = charHpArray;
}
public int[] getCharHp() {
return charHpArray;
}
小怪兽爱吃肉
相关分类