我正在尝试为大学(大一)的项目制作一个游戏,这个项目在控制台中运行,用一种我自学的语言,因为它是我认识最好的那种,但我是遇到很多问题,因为我很新,很抱歉,如果问题很明显/不好。
基本上它应该如何工作是一个玩家可以选择一个魔法学校,然后将添加来自该学校(类型)魔法的三个法术,并且玩家需要选择3个学校然后被分配到他们的1-9键。游戏是基于回合的,我提前考虑过,但是当我尝试创建拼写对象时,我收到错误The constructor Spell (String, int, int, String, String, String) is undefined
和the value of (insert whatever spell name here) is not used.
。现在第二个是真的,但它不应该使程序不可用,因为它将在以后使用,但我不明白为什么第一个出现在我做那个构造函数的时候,抱歉如果这个问题有点乱再次,这是代码。
public class Spell {
int damage;
int absorb;
String type;
String priority;
String name;
public Spell(String name, int damage, int absorb, String type, String priority, String direction){
System.out.println("\nYou learned: " + this.name);
}
}
玩家类是:
public class Player {
int hp = 100;
String type1,type2,type3;
public void Types() {
Scanner scan = new Scanner(System.in); //lets both players choose their three spell types
int i = 0;
System.out.println("Choose your first element : \n 1.Frost\t\t2.Lighting\t\t3.Earth\n 4.Fire\t\t5.Water\t\t6.Wood\n 7.Wind\t\t8.Runes\t\t9.Chaos ");
while (i > 3){
if (i == 1 || i == 2){
System.out.println("Choose your next element : \n 1.Frost\t\t2.Lighting\t\t3.Earth\n 4.Fire\t\t5.Water\t\t6.Wood\n 7.Wind\t\t8.Runes\t\t9.Chaos ");
}
int pick = scan.nextInt(); //i increases every time the player picks a type, type is stored to the position and will be assigned
// controls based on what position the type is in (type1 - 1,2,3; type 2 - 4,5,6 etc)
if (pick == 1){ // for every CHOOSEN type it creates three objects from the spell class
Spell frostBolt = new Spell("Frost bolt", 20, 0, "Frost", "Attack", "Projectile");
Spell coneOfCold = new Spell ("Cone of Cold", 5, 0, "Frost", "Defense", "Cone");
Spell icedEarth = new Spell("Iced Earth", 0, 0, "Frost", "Field", "Ground");
if (i == 0){
type1 = "frost";
}
else if (i == 1){
type2 = "forst";
}
else{
type3 = "frost";
}
i++;
}
else if (pick == 2){
Spell thunder = new Spell("Thunder", 15, 0, "Lightning", "Attack", "Overhead");
Spell staticField = new Spell ("Static Field", 5, 0, "Lightning", "Field", "Air");
Spell absortionBlast = new Spell("Absortion Blast", 0, 100, "Lightning", "Defense", "Self");
if (i == 0){
type1 = "lightning";
}
else if (i == 1){
type2 = "lightning";
}
else{
type3 = "lightning";
}
i++;
}
等
有没有OOP相关的东西,我做错了,我真的无法理解,已经在几个小时内反击它,提前感谢!