I'm developing a simple game. I created a class called Monster with a constructor to act as a basic template for all monsters. Here is the Monster class:
public class Monster {
public int attackPower;
public String weaponName;
public int armorLevel;
public String armorName;
public int life;
public String monsterClass;
public String monsterName;
public int monsterNumber;
public Monster(int attackPower, String weaponName, int armorLevel, String armorName, int life, String monsterClass, String monsterName, int monsterNumber) {
this.attackPower = attackPower;
this.weaponName = weaponName;
this.armorLevel = armorLevel;
this.armorName = armorName;
this.life = life;
this.monsterClass = monsterClass;
this.monsterName = monsterName;
this.monsterNumber = monsterNumber;
}
}
Here is the class I put together to test the constructor:
public class Area1Monsters extends Monster {
public static void main(String[] args) {
Monster rat1 = new Monster(1, "Claws", 3, "Fur", 9, "Fields", "Rat", 1);
System.out.println("Attack Power: " + rat1.attackPower);
System.out.println("Weaon Name: " + rat1.weaponName);
System.out.println("Armor Level: " + rat1.armorLevel);
System.out.println("Armor Name: " + rat1.armorName);
System.out.println("HP: " + rat1.life);
System.out.println("Starting Area: " + rat1.monsterClass);
System.out.println("Name: " + rat1.monsterName);
System.out.println("Monster Number: " + rat1.monsterNumber);
}
}
The error says constuctor Monster in class Monster cannot be applied to given type;
required: int, java.lang.String, int, java.lang.String...etc.
I believe I have correctly matched each of the data types from the constructor to the application of the object creation of rat1, but I'm clearly missing something. I'm sure it's obvious and basic. Any help would be very much appreciated.
Monsterfor your main class. It probably should not extendMonster, and if it should, you'll need to properly call the super constructor.