The original problem is:
We have a bus, and we want to manage the payment methods for people. We have 2 types of people that can get on the bus: regular citizens and students. Citizens can pay with either a credit card or cash. Students can pay using the methods citizens use, or with a special student card. Every student has exactly one student card.
How should the inheritence tree look like? I'm not sure what's the best way to make the student card be usable only by students without hurting the OOP principles, or what design patterns should (or shouldn't) I use.
Aucun commentaire:
Enregistrer un commentaire