Making a Deck of Cards with an Array.

I am just starting a long journey for me (a beginner) towards re-creating a card trick that I know that is mathematical.

I realized awhile back that I could re-create it with OOP and thought it would be a great lesson for me to do.

FIRST step however, is just creating the deck!

I thought I could do a Jagged Array --
string[][] fullDeck = new string[][]
{new string[] {"H","C","S","D"}, new string[] {"A","2","3"}};


But I obviously dont understand this type of Array enough because when i try and print it out to console I only get the second array values --- i.e . fullDeck[1],[1] prints out "2" only.

I was hoping it would print out "C2" (2 of Clubs) yet I suck.... Can anyone tell me what I am doing wrong or is there a better way (EASY way).

I have seen many examples on the net from people making games and such but they are WAY over my head. Right now, my final goal is simply text in a Console screen.

Any help?

Comments

  • : I am just starting a long journey for me (a beginner) towards re-creating a card trick that I know that is mathematical.
    :
    : I realized awhile back that I could re-create it with OOP and thought it would be a great lesson for me to do.
    :
    : FIRST step however, is just creating the deck!
    :
    : I thought I could do a Jagged Array --
    : string[][] fullDeck = new string[][]
    : {new string[] {"H","C","S","D"}, new string[] {"A","2","3"}};
    :
    :
    : But I obviously dont understand this type of Array enough because when i try and print it out to console I only get the second array values --- i.e . fullDeck[1],[1] prints out "2" only.
    :
    : I was hoping it would print out "C2" (2 of Clubs) yet I suck.... Can anyone tell me what I am doing wrong or is there a better way (EASY way).
    :
    : I have seen many examples on the net from people making games and such but they are WAY over my head. Right now, my final goal is simply text in a Console screen.
    :
    : Any help?
    :

    I'm sorry to say it but you're thinking all wrong...
    [code]
    char[] colors = {'H','C','S','D'}
    char[] deck = {'A','2','3','4'}

    console.writeline(colors[1], deck[1]);
    [/code]

    I could tell you why you get the result you get on your code but that won't help you...

    Here's a func:
    [code]
    const char[] colors = {'H','C','S','D'}
    const char[] deck = {'A','2','3','4'}

    string fulldeck(short i, short j){
    return colors[i].toString()+ deck[i].toString();
    }
    [/code]

    I may be wrong somewhere. It was a long time since I did C# (almost a year ago...)
  • [b][red]This message was edited by bmjcpo at 2006-8-29 8:15:51[/red][/b][hr]
    : : I am just starting a long journey for me (a beginner) towards re-creating a card trick that I know that is mathematical.
    : :
    : : I realized awhile back that I could re-create it with OOP and thought it would be a great lesson for me to do.
    : :
    : : FIRST step however, is just creating the deck!
    : :
    : : I thought I could do a Jagged Array --
    : : string[][] fullDeck = new string[][]
    : : {new string[] {"H","C","S","D"}, new string[] {"A","2","3"}};
    : :
    : :
    : : But I obviously dont understand this type of Array enough because when i try and print it out to console I only get the second array values --- i.e . fullDeck[1],[1] prints out "2" only.
    : :
    : : I was hoping it would print out "C2" (2 of Clubs) yet I suck.... Can anyone tell me what I am doing wrong or is there a better way (EASY way).
    : :
    : : I have seen many examples on the net from people making games and such but they are WAY over my head. Right now, my final goal is simply text in a Console screen.
    : :
    : : Any help?
    : :
    :
    : I'm sorry to say it but you're thinking all wrong...
    : [code]
    : char[] colors = {'H','C','S','D'}
    : char[] deck = {'A','2','3','4'}
    :
    : console.writeline(colors[1], deck[1]);
    : [/code]
    :
    : I could tell you why you get the result you get on your code but that won't help you...
    :
    : Here's a func:
    : [code]
    : const char[] colors = {'H','C','S','D'}
    : const char[] deck = {'A','2','3','4'}
    :
    : string fulldeck(short i, short j){
    : return colors[i].toString()+ deck[i].toString();
    : }
    : [/code]
    :
    : I may be wrong somewhere. It was a long time since I did C# (almost a year ago...)
    :


    The code shown in IDK's reply will work I suppose, but if you like to use multi-dimensional array's, as I understand, you might check the msdn-site: http://msdn2.microsoft.com/en-us/library/2yd9wwz4.aspx

    It's quite difficult to explain it just in a forum, not knowing your level of coding. Maybe some tutorials might help.
    good luck.


  • Thanks a ton guys! I have gotten alot closer through the use of some single arrays and multiple if statements. This is just the first step. I do need to keep taking classes and trying different tutes.
    Thanks a million!


    : [b][red]This message was edited by bmjcpo at 2006-8-29 8:15:51[/red][/b][hr]
    : : : I am just starting a long journey for me (a beginner) towards re-creating a card trick that I know that is mathematical.
    : : :
    : : : I realized awhile back that I could re-create it with OOP and thought it would be a great lesson for me to do.
    : : :
    : : : FIRST step however, is just creating the deck!
    : : :
    : : : I thought I could do a Jagged Array --
    : : : string[][] fullDeck = new string[][]
    : : : {new string[] {"H","C","S","D"}, new string[] {"A","2","3"}};
    : : :
    : : :
    : : : But I obviously dont understand this type of Array enough because when i try and print it out to console I only get the second array values --- i.e . fullDeck[1],[1] prints out "2" only.
    : : :
    : : : I was hoping it would print out "C2" (2 of Clubs) yet I suck.... Can anyone tell me what I am doing wrong or is there a better way (EASY way).
    : : :
    : : : I have seen many examples on the net from people making games and such but they are WAY over my head. Right now, my final goal is simply text in a Console screen.
    : : :
    : : : Any help?
    : : :
    : :
    : : I'm sorry to say it but you're thinking all wrong...
    : : [code]
    : : char[] colors = {'H','C','S','D'}
    : : char[] deck = {'A','2','3','4'}
    : :
    : : console.writeline(colors[1], deck[1]);
    : : [/code]
    : :
    : : I could tell you why you get the result you get on your code but that won't help you...
    : :
    : : Here's a func:
    : : [code]
    : : const char[] colors = {'H','C','S','D'}
    : : const char[] deck = {'A','2','3','4'}
    : :
    : : string fulldeck(short i, short j){
    : : return colors[i].toString()+ deck[i].toString();
    : : }
    : : [/code]
    : :
    : : I may be wrong somewhere. It was a long time since I did C# (almost a year ago...)
    : :
    :
    :
    : The code shown in IDK's reply will work I suppose, but if you like to use multi-dimensional array's, as I understand, you might check the msdn-site: http://msdn2.microsoft.com/en-us/library/2yd9wwz4.aspx
    :
    : It's quite difficult to explain it just in a forum, not knowing your level of coding. Maybe some tutorials might help.
    : good luck.
    :
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories