View Single Post
  #1 (permalink)  
Old September 17th, 2013, 07:32 PM
HVDL47 HVDL47 is offline
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch10CardLib - Deck class

Hi all, I am new to C# and new to this forum. Decided to learn c# two months ago and started with Beginning Visual C#2010. Didnt need any help till now. Maybe its really simple, but I just dont see it. I just dont get the following in bold (the 13 at least makes sence, feeling whise, since there are 13 cards per suit, but I really cant place the -1):

Code:
public class Deck
{
    private Card[] cards;
    
    public Deck()
    {
        cards = new Card[52];
        for (int suitVal = 0; suitVal < 4; suitVal++)
        {
            for (int rankVal = 1; rankVal < 14; rankVal++)
            {
                 cards[suitVal * 13 + rankVal -1] = new Card((Suit)suitVal,
                                      (Rank)rankVal);
             }
        }
}
I could also a check up so could everyone be so kind to explain what happens line by line and put special focus on the part in bold? Much appreciated.

Hvdl47