Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OOP Interview Question
Message
 
À
26/01/2006 10:50:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01090521
Message ID:
01090816
Vues:
8
>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
Fil
Voir

Click here to load this message in the networking platform