I have a few classes something like this:
public class Weapon
{
public static int clip;
}
public class Uzi : Weapon{}
public class Ak47 : Weapon{}
Somewhere else in main code I have:
Uzi.clip = 5;
Ak47.clip = 1;
Will this work, will UZI have its own unique clip or same as AK47? If not how to achieve this?
This is simplified version above, what I have behind is much more complex but I just need an Idea how to do this.
Why not try it?
It does not work, as both referring to the same
clip. (No difference here, but if it was a string you could test and prove they were the same object).The best you can do is:
If you want individual weapons to have a
Clipthat differs then you want different code again.