This is because you have a method that you never call.
Although you can add calls to setSvanslängd
method to your main
to fix this problem, this is not the best approach: it would be much better to set the length of the tail in the constructor, and never touch it again. This would be a much more intuitive solution:
public Hund(String namn , int ålder , int vikt, String ras) {
this.namn = namn;
this.ålder = ålder;
this.vikt = vikt;
this.ras = ras;
// Set the length of the tail
if(ras.equalsIgnoreCase("tax")) {
svanslängd = 3.7;
}else{
svanslängd = (ålder * vikt)/10.0;
}
}