Trying to get better at programming. Working on building a silly game to teach myself, so its like an RPG type.
Inside the main:
String selection = "Warrior";
if(selection == "Warrior")
{
Warrior war = new Warrior();
characterCreation(player, war, 75, 200, "Black", 150, 90, 25);
}
Just to create a generic character:
private static void characterCreation(User player, Character type, int armour, int health, String colour, int height, int weight,
int damage) {
type.setType(type);
System.out.println("New "+ type.getType() +" Created!");
So the idea is that you can create a warrior, healer, wizard you get the idea 🙂
Character.java
private Character type;
public Character getType() {
return type;
}
public void setType(Character type) {
this.type = type;
}
Then empty Warrior.java class that extends the Character class.
The output im getting when it gets printed is New com.game.config.Warrior@6471d768 Created!
What am I doing wrong here?
Thanks!
Give your classes a viable
public String toString()method that makes sense — that returns a String that describes the current object and its state. That will fix your “com.game.config.Warrior@6471d768” problem since what you’re seeing is the default String returned from Object’stoString()method.