First
Avoid the name Character
because there is a class in java.lang
package that is named Character
which is a wrapper class for the primitive data type char
.
The java.lang.Character
class is used for auto-boxing conversions, more info here
Second
Rename that class to Champion
and it will definitely work. :)
Third
you are not passing proper parameters to the arguments. Your constructor needs parameters while you left the parantheses blank
What it looks like
public class Character {//<-- avoid this name
public int attack, rangedAttack, manaAttack, defense, rangedDefense, manaDefense, strength, agility, intelligence ,race;
String name;
public Character(String Name, int Race) {
name = Name;
race = Race;
};//<-- Y U PUT SEMICOLON ?
public class QuestOfVallock{
public static void main(String[] args){
Character self = new Character(); //<-- Y U NO GIVE HIM PARAMETERS ?
}
What it should be
public class Champion { //<-- Java-approved name
public int attack, rangedAttack, manaAttack, defense, rangedDefense, manaDefense, strength, agility, intelligence ,race;
String name;
public Character(String Name, int Race) {
name = Name;
race = Race;
}//<-- No semicolon
}//<-- Closing brace for class
public class QuestOfVallock{
public static void main(String[] args){
Champion self = new Champion("Little Java Child",1001); //<-- Unique race
}
}//<-- closing brace for class
What I also suggest is making your
Race
some constants in an
interface
public interface RaceConstants {
int ELF = 1;
int JAVA_CHILD = 1001;
int DWARF = 2;
}
so your main()
looks like this:
public static void main(String[] args){
Champion self = new Champion("Little Java Child",RaceConstants.JAVA_CHILD; //<-- Unique race
}