>I'm a big believer that if your a good coder in a different language you'll be a good coder in any language - because it's about the logic and the rest is just syntax. So I was looking for an OOP question that didn't rely on FoxPro knowledge and came up with. Can you describe a deck of cards as objects? Telling me what classes you would create and what properties and methods you would put in each class. To this date only 1 person has ever given me a good response on this question. Is it too tuff of a question or is it a bad question?
There are a number of ways to do this, depending on what you are going to do the the objects, or which kind of problem you will be solving. which of these would you consider a good response?
SOLUTION 1:
- class called card
- card has two properities face (2-A) and suit
- to represent a card, instantiate the class into 52 objects then assign the face and suit
SOLUTION 2:
- have a class called deck
- have class called card from solution 1, with the same properties
- have a method called create() on deck that creates a collection of card objects, 1 for each of the 52 cards
SOLUTION 3:
- a class called card
- card has 4 methods, GetSuit(), SetSuit(), GetFace(), SetFace()
- have methods instead of properties, means that the object doesn't have to maintain state, which may be appropriate in some cases
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement