RichLLR
Technical User
- Apr 3, 2009
- 3
I have a background in relational database modeling and have been trying to get to grips with oop for about a week now. I'm sure I have either missed or am mis-understanding something. As an exercise I am trying to build a small web app based on pontoon using asp.net, Ajax & javascript. Obviously there are better ways to achieve this but this allows me to base the design on what I thought would be a couple of fairly basic objects.
I believe a 'PackOfCards' HasA 'Card'. For instance parameters such as 'cardStyle' belong to 'PackOfCards' while 'suit', 'number' etc belong to 'Card'. My confusion begins with Methods. For instance; 'DisplayCard()' is a member of 'Card' as I'm only ever interested in writing the html for a single card (I would use Draw() as the name but that could get confusing). However 'Shuffle()' would be a member of 'PackOfCards' as you can't and wouldn't want to shuffle a single card. But with the way inheritance works every 'Card' would inherit the method 'Shuffle()' which doesn't seem right to me.
Where have I got turned around? Am I simply being too literal with my objects? Thanks for any help in advance.
I believe a 'PackOfCards' HasA 'Card'. For instance parameters such as 'cardStyle' belong to 'PackOfCards' while 'suit', 'number' etc belong to 'Card'. My confusion begins with Methods. For instance; 'DisplayCard()' is a member of 'Card' as I'm only ever interested in writing the html for a single card (I would use Draw() as the name but that could get confusing). However 'Shuffle()' would be a member of 'PackOfCards' as you can't and wouldn't want to shuffle a single card. But with the way inheritance works every 'Card' would inherit the method 'Shuffle()' which doesn't seem right to me.
Where have I got turned around? Am I simply being too literal with my objects? Thanks for any help in advance.