For our school we got an assignement that said we had to make a cardgame, we chose blackjack.
We ran into a little problem at the beginning. we can make an array, but we can't use it to put our cards in !!
can anyone please help us ?
this is the code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using System.Collections;
using System.Text;
namespace BlackJackOpdracht
{
class Game
{
Dealer dDealer = new Dealer();
Speler sSpeler = new Speler();
Array[] mArray = new Array[52];
protected string mAfbeeldingsPad;
protected Image mAfbeelding;
public Game ()
{
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 14; j++)
{
mAfbeeldingsPad = "/Images/" + Convert.ToString(i) + "-" + Convert.ToString(j)+".png";
mAfbeelding = Image.FromFile(Convert.ToString(mAfbeeldingsPad));
mArray.push???????
}
}
}
}
}
}
grts
Nsmet
Sam HobbsPosted Feb 23, 2012, 4:00 AM
I think this is an excellent example for learning object-oriented philosophy. You should have a Card class that is used for each of the 52 cards. Also a Card Deck class. The details of the design of each is up to you. You might also want a Player class and perhaps a separate class for the Dealer. The Dealer class might be derived from the Player class.
It is up to you to decide where the method for shuffling the deck should belong. It could be in the Card Deck class or it could be in the Dealer class.
This example shows how complex things can be that seem very simple for us. The details of how to represent what a card is is not as easy as most people would think.
If you use a "for" statement such as what you did in the code you posted then I thnk you want to use "i < 4" not "i < 5" and use "j < 13" instead of "j < 14".
FroglegPosted Feb 22, 2012, 3:32 PM