Superclass and Inheritance question.
A few weeks ago I began my endeavor of a open ended project for learning. However it stalled due to some circumstances and now I'm back at it.
Details aside, I have a superclass with variables that are private. I also have my subclass which I want to inherit those variables and modify them.
public class Weapon
private string name;
public void setName(newName)
name = newName;
public string getName()
The problem I'm coming across is that when I create a Dagger object it inherits the string name from Weapon, not Dagger. Which by default is null. My question is, how do I make it so that when I create a Dagger object it inherits all of the methods from Weapon, yet overrides the variables?
public class Dagger extends Weapon
//Overriding code not related to question
private string name = "Dagger";