Assigning data?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Assigning data?

  1. #1
    Join Date
    Feb 2012
    Posts
    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

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,474

    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 code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center