Gary Charles wrote:
The Card object is created with the constructor and during instantiation in DeckOfCards.java on line 26 the suit and face are sent along. So the object contains the suit and face. Then when I make a new array on line 40 and assign it on line 41, the fields(?) suit and face are sent along with it as well. Since the fields suit and face are of type Card the getter has the ability to retrieve them. Kind of fuzzy. Is that close to accurate?
Gary
The suite and face aren't "sent along".
Remember that in
Java, variables hold references to Object, not the objects themselves. Also, Arrays contains references to objects too, not the object themselves. On line 21, you create an Array, and what that means is that an empty array is creates, and the reference to the array is stored in
deck. In line 26, you create a
Card object and store it's
reference in the array
Now in line 40, you create another array of size 1. In line 41, you copy the
reference of the first card in the
deck to the first element in the
hand array. Remember that the reference is copied, not the Object.. both references point to the same Card object. so, doing
hand[0].getFace() is doing the same thing as
deck[0].getFace()
I know it can get confusing. It will help if you make a little drawing that shows which variables contain references to which objects
Edited: You might want to read
Cup Size campfire story