So if I have a class gameObject and a bunch of classes that extend it:
class gameObject {
int u = 0;
public gameObject() {
}
}
class Spaceship extends gameObject {
    int u = 5;
    // Constructor
    public Spaceship() {
    }
}
class Alien extends gameObject {
    int u = 6;
    public Alien() {
    }
}
public class test {
    public static int overlapping(gameObject b, gameObject a) {
        return (b.u - a.u);
    }
    public static void main(String[] args) {
        System.out.println(overlapping(new Alien(), new Spaceship())); 
    }
}
When the difference method runs, it computes 0 - 0 regardless of if a Spaceship, alien is passed into it. But I want it to take either of the 2 (Spaceship, Alien), and return the difference of their specific u values.
But indicating the type of a and b parameters as gameObject just results in the u value being taken as 0 instead of the specific values. What do I do here?
I thought that since all 2 extended gameObject, I could just say that the parameters were of gameObject type, but that didn't seem to work. I tried doing <T extends gameObject> and then Class <T> a and Class <T> b, but then it says that it cannot the constant u.
 
     
     
    