I am trying to make a constructor for a text-based game that I am making for fun and cannot get the Character constructor to take a String and int. When used it requires only a char.
public class Character {
public int attack, rangedAttack, manaAttack, defense, rangedDefense, manaDefense, strength, agility, intelligence ,race;
String name;
public Character(String Name, int Race) {
name = Name;
race = Race;
};
This is where I try to use the constructor.
public class QuestOfVallock{
public static void main(String[] args){
Character self = new Character();
}
It looks like a namespace collision with java.lang.Character.
Try declaring a package to avoid ambiguity or rename the Character class to something else.
Then instantiate your Character class like this:
Update: As others have pointed out, Java does not create a default constructer (one with no parameters) for you if you have one or more constructors defined. But I still stand by my answer that packages are the way to go. The use of the default package is discouraged and only exists for small applications beginning development. See Is the use of Java's default package a bad practice?