If you have a member variable in a base class you want to be visible to the subclasses but not to any unrelated classes, then declare that variable as protected.
Example:
public abstract class Item {
protected bool isBought;
public abstract void Buy();
}
/*-------------------------------*/
public class Sword : Item {
public void Buy() {
if (isBought) {
Console.log("You can only use one sword, there is no point in buying another one");
} else {
Console.log("You purchased a sword!");
isBought = true;
}
}
}
/*-------------------------------*/
public class Shield : Item {
public void Buy() {
if (isBought) {
Console.log("Shields are heavy. You can't carry more than one.");
} else {
Console.log("You purchased a shield!");
isBought = true;
}
}
}
Note that each instance of Item has a separate value for isBought. So the code above assumes that each of those child-classes only has one instance. If you have multiple instances of Sword, the isBought status is traced for each of those separately.
If your architecture assumes that there can be multiple instances of Sword, but you only ever want the player to own one of them, then it gets a bit more complicated. In that case I would implement a separate class Inventory which keeps track of what the player owns and which has some public methods which can be used to check if the player does or does not have an item matching some criteria.