Hi! I'm trying to to get a subclass method to return the variable from the superclass, however the return value keeps giving me empty returns. My guess would be that i'm missing some kind of reference to the super class. It's the value weight that returns value 0(zero) from the subclass method returnweight().
abstract class Vehicle{
protected float weight;
public Vehicle(float weight){
}
public abstract float returnweight();
}
class Bike extends Vehicle{
public Bike(float weight){
super(weight);
}
public float returnweight(){
return weight;//This returns as zero no matter what
}
}
The code is condensed and translated(not compiler-checked syntax in this post) Thanks in advance!