generating a random value from a fix array that set as a class?
<p>we are working on a school project (a learning game) and atm we are using a class that generate a value from a "Stack". our problem is that after the values of the stack runs out the game / program crash and stops.</p>

<p>i want to change it to a array with fix values and cells in it that gives me a random value each time that i address it. </p>

<p>right now the code is this:</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// &lt;summary&gt;
/// Summary description for CellInfoRepository
/// &lt;/summary&gt;
public class CellProducer
{
    System.Collections.Generic.Stack&lt;Cell&gt; _stack = new Stack&lt;Cell&gt;();



    public CellProducer()
    {



        _stack.Push(new Cell { InstrumentName = "גיטרה", InstrumentFamily = 1, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "עוד", InstrumentFamily = 1, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "סיטאר", InstrumentFamily = 1, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "כינור", InstrumentFamily = 1, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "צ'לו", InstrumentFamily = 1, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "ויולה", InstrumentFamily = 1, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "נבל", InstrumentFamily = 1, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "בנג'ו", InstrumentFamily = 1, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "תופים", InstrumentFamily = 2, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "מצילה", InstrumentFamily = 2, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "שליש", InstrumentFamily = 2, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "קסטנייטה", InstrumentFamily = 2, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "פעמוניה", InstrumentFamily = 2, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "קסילופון", InstrumentFamily = 2, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "טמבורין", InstrumentFamily = 2, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "פעמוני רוח", InstrumentFamily = 2, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "קרן יער", InstrumentFamily = 3, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "בריטון", InstrumentFamily = 3, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "טרומבון", InstrumentFamily = 3, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "טובה", InstrumentFamily = 3, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "סקסופון", InstrumentFamily = 3, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "חליל", InstrumentFamily = 3, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "קלרינט", InstrumentFamily = 3, myPlayer = 0 });
        _stack.Push(new Cell { InstrumentName = "משרוקית", InstrumentFamily = 3, myPlayer = 0 });
    }

    public Cell ProduceNextCell()
    {
        return _stack.Pop();
    }
}
</code></pre>

<p>any idea how i keep the name of the class, but only change the inside for a array that generade random values?</p>

<p>btw, the "cell" is another class that we made, and the array should be made from him:</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

/// &lt;summary&gt;
/// Summary description for Cells
/// &lt;/summary&gt;
public class Cell:Panel //מחלקת משושים
{
    protected string _instrumentName; //שם כלי הנגינה  //
    protected int _insturmentFamily; //סוג כלי הנגינה - המשפחה //
    protected int _myPlayer; //ערכים מספריים של 0 - אין שחקן - 1 ו2 לפי השחקנים

    public string InstrumentName
    {
        get
        {
            return _instrumentName;
        }

        set
        {
            _instrumentName = value;
        }
    }

    public int InstrumentFamily
    {
        get
        {
            return _insturmentFamily;
        }

        set
        {
            _insturmentFamily = value;
        }
    }

    public int myPlayer
    {
        get
        {
            return _myPlayer;
        }

        set
        {
            _myPlayer = value;
        }
    }
}

public class CellPosition // מחלקה ששומרת את מיקומי התאים
{
    private int _Column;
    private int _Row;

    public int Column
    {
        get
        {
            return _Column;
        }

        set
        {
            _Column = value;
        }
    }

    public int Row
    {
        get
        {
            return _Row;
        }

        set
        {
            _Row = value;
        }
    }
}
</code></pre>

<p>thanks for the help and sorry for all the notes in Hebrew! </p>
