What is a Data Member? Help.

Hi i'm pretty new to programming and i'm learning java at the moment. Im confused as to what a data member actually is, im working on a practice program and in the description for one of the class's i have to create it says this

"# Define classes for the Number, Shape, Color and Shading properties such that objects of each type can only be one of the three corresponding values for that type.

# Define a Card class that has data members for each of the properties defined in the previous step. The Card must also have a "toString()" function that returns a textual description of its properties (e.g. "3 Blue Striped Diamond"). "

I'm not quite sure what its asking, and also i don't understand why they would want me to create separate classes for each property of a card instead of just having instance variables for each property defined in the card class itself. any help would be appreciated please.

[936 byte] By [dets00ba] at [2007-11-26 19:01:16]
# 1

;) As far as I understand it. That is exactly what they want.

"Data Member" seems their term for instance variable.

So objects of your Card class must have four instance variables (Data Members) one for each property.

Now you could e.g. say the Shape property is a simple string, but than you must provide a means of guaranteeing that this property never assumes a value like "potatoe shaped" as this is not a valid shape.

So instead of a String you can define a class CardShape, that can only hold allowed shape information. The 'Data Member' would than be of that class.

g_magossa at 2007-7-9 20:45:37 > top of Java-index,Java Essentials,Java Programming...
# 2
ah i understand now, thank you for your speedy reply, much appreciated :P
dets00ba at 2007-7-9 20:45:37 > top of Java-index,Java Essentials,Java Programming...