-
February 10th, 2012, 05:45 AM
#1
Assigning data?
Hello,
Im new to java and have a question about an assignment I received. If this is not permitted, simply let me know.
I'm confused as to how to assign data to a value and a null string. Here are the first 2 instructions:
a) Use only two private instance variables rank and suit. rank is an integer holding the numeric value of one through thirteen representing the Ace through the King. suit is a String holding the values of either: "clubs", "diamonds", "hearts", or "spades".
b) Write a no argument method, setCard(), assigning data to a value of 1(ace) and a null string.
I am having trouble understanding part b. I understand that rank is an int array but I have no idea how to assign data to both an int and a string.
Thank you
-
February 10th, 2012, 08:31 AM
#2
Re: Assigning data?
Im new to java and have a question about an assignment I received. If this is not permitted, simply let me know.
This is ok, asking for the answer or the code is not.
I am having trouble understanding part b. I understand that rank is an int array
No, it says rank is an integer holding a value in the range of 1 to 13. It doesn't say it's an array.
but I have no idea how to assign data to both an int and a string.
The question is badly worded, are you sure this is exactly what you were asked to do?
assigning data to a value of 1(ace) and a null string.
Taken on it's own this makes no sense and even when taken in conjunction with part a it makes little sense. I would say it probably means assign the value 1 to rank and null to suit. ie set suit to be a null string.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|