I have a superclass called Seat
(for a concert hall).
GoldSeat
, SilverSeat
and BronzeSeat
are its subclasses.
I've always read to keep data private
so as to enable encapsulation.
If I need to write methods that use these instance variables in the subclasses, is it considered acceptable to make them protected
? Most of the similar stack overflow questions don't address correct object-oriented design, but rather focus on differences between access modifiers and the processing efficiency or technical difference of each. If I missed one, I apologise in advance and will happily review it.
I could use getter methods in the subclasses to get the instance variables, but that seems bizarre in this case, but at least the data would be private
.