Class Inheritance and Propertys

Mar 13 2006 4:20 PM
I have been wondering how to implement "class inheritance" so you can write code that looks something like program below. I want to make a class object like "player" with array index, then call to "Card" property which I want to have array indexed as well, and also inherits GetSuit() and GetValue() functions.

The two classes below are just something to start with. Because Im new to this kind of structure, can anyone point out what technology is used, give some examples or information on how to get them. Thanks :)

namespace ConsoleDebugger
{
    class Program
    {
	static public Player[] player = new Player[2];
	static public Deck deck = new Deck();

	static void Main(string[] args)
        {
		// How to implement this structure...
		player[0].Cards[0].GetSuit();

		// and how this function can store into the hand object...
		player[0].GrabCard( deck.DealNext() );
        }
    }
}


public class Player
{

	public void GrabCard(int SomeCard)
	{
		// stores into same card object...
	}

	public int Hand
	{
		// Inharets from Hand GetSuit() and GetValue()...
	}
}


public class Card
{

	private int[] yourCards = new int[2];

	public int this[int index]
	{
		get { return yourCards[index]; }
		set { yourCards[index] = value; }
	}

	public int GetValue()
	{
		// ???
	}

	public int GetSuit()
	{
		// ???
	}
}