I have been working on a project which is creating a deck of cards for a windows application. So far, I was able to create a list that would hold all 52 cards. Along with that, an imagelist is used to store each card's image. The problem that I'm trying to solve is that I need to store each card's image corresponding to each element that is stored to the list.
So far, the result is displayed like this:
2 of Clubs,
3 of Clubs,
4 of Clubs,
5 of Clubs,
.
.
.
Jack of Clubs,
Queen of Clubs,
King of Clubs,
Ace of Clubs
Below is my working code:
for (i = 0; i < 4; i++)
{
suit = i.ToString();
switch (suit)
{
case "0":
suit = "Clubs";
break;
case "1":
suit = "Diamonds";
break;
case "2":
suit = "Hearts";
break;
case "3":
suit = "Spades";
break;
}
for (k = 0; k < 13; k++)
{
// face = k.ToString();
face = k.ToString();
switch (face)
{
case "0":
face = "2";
break;
case "1":
face = "3";
break;
case "2":
face = "4";
break;
case "3":
face = "5";
break;
case "4":
face = "6";
break;
case "5":
face = "7";
break;
case "6":
face = "8";
break;
case "7":
face = "9";
break;
case "8":
face = "10";
break;
case "9":
face = "Jack";
break;
case "10":
face = "Queen";
break;
case "11":
face = "King";
break;
case "12":
face = "Ace";
break;
}
cardDeckList.Add(new PlayingCard(suit, face, imageListCards.Images[counter], 1));
counter++;
}
}
for (int l = 0; l < cardDeckList.Count; l++)
{
listBoxOutput.Items.Add(cardDeckList[l].ToString());
pictureBox_Card1.Image = cardDeckList[l].CardImage;
}
My goal is that I have set and upload the images in a certain order within the imagelist. Thus, I would like to store each newly created element's values such as the suit, face value, and the image correspondingly to the imagelist's list of images.
As of now, below of this contains an image of how the images are stored like in the imagelist. Furthermore, beneath of this contains my current working windows application.
You do not say this is a website or windows Application. I think you have a web application
this is a sample web page and i hope helping you to create your own
Web C# (Code Behind)
Web Markup
Windows App PlayingCard Class
Windows App button click
Windows App
designer
Windows App
output