InheritanceThe idea that inheritance must be avoided is simply wrong.
There
There exists a coding principle called Composition over InheritanceComposition over Inheritance. It says, that you can achieve simmilar resultsthe same things with composition, and it's preferable, because you can reuse some of the code. Source:See
SE-StackexchangeWhy should I prefer composition over inheritance? also look here at the other Answers.
Wikipedia
I have to say iI like your weapon classes and would it do the same way. But i haven't made a game by now...
As
As pointed out by James Trotter, composition could have some advantages, especially in the flexibility at runtime to change how the weapon works. This would be possible with inheritance, but it's more difficult.