Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7586421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:25:32+00:00 2026-05-30T19:25:32+00:00

we are working on a school project (a learning game) and atm we are

  • 0

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.

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.

right now the code is this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

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



    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();
    }
}

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

btw, the “cell” is another class that we made, and the array should be made from him:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

/// <summary>
/// Summary description for Cells
/// </summary>
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;
        }
    }
}

thanks for the help and sorry for all the notes in Hebrew!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:25:34+00:00Added an answer on May 30, 2026 at 7:25 pm

    I haven’t tested it, but i think it would work:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    /// <summary>
    /// Summary description for CellInfoRepository
    /// </summary>
    public class CellProducer
    {
        System.Collections.Generic.List<Cell> cells = new List<Cell>();
        Random random = new Random();
    
        public CellProducer()
        {
            cells.Add(new Cell { InstrumentName = "גיטרה", InstrumentFamily = 1, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "עוד", InstrumentFamily = 1, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "סיטאר", InstrumentFamily = 1, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "כינור", InstrumentFamily = 1, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "צ'לו", InstrumentFamily = 1, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "ויולה", InstrumentFamily = 1, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "נבל", InstrumentFamily = 1, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "בנג'ו", InstrumentFamily = 1, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "תופים", InstrumentFamily = 2, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "מצילה", InstrumentFamily = 2, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "שליש", InstrumentFamily = 2, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "קסטנייטה", InstrumentFamily = 2, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "פעמוניה", InstrumentFamily = 2, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "קסילופון", InstrumentFamily = 2, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "טמבורין", InstrumentFamily = 2, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "פעמוני רוח", InstrumentFamily = 2, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "קרן יער", InstrumentFamily = 3, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "בריטון", InstrumentFamily = 3, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "טרומבון", InstrumentFamily = 3, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "טובה", InstrumentFamily = 3, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "סקסופון", InstrumentFamily = 3, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "חליל", InstrumentFamily = 3, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "קלרינט", InstrumentFamily = 3, myPlayer = 0 });
            cells.Add(new Cell { InstrumentName = "משרוקית", InstrumentFamily = 3, myPlayer = 0 });
        }
    
        public Cell ProduceNextCell()
        {
            return cells[random.Next(cells.Count)];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a school project and I'm getting some weird errors from Xcode.
greeting all i am working on school project and i have a problem with
I am working on a school project that uses ASP.NET. I found this TextEditor
I'm working on a school project desktop application in c# using Visual Studio 2010
I'm currently working on a school project in Eclipse (We have just started using
My question is about a school project that I'm working on. It involves mapping
So I'm working on developing a game for a school project and so far
I am working on a school project using Spring MVC (Spring 3.0.0). Now everything
I'm working on a project at school for my data mining class and I
I'm working on a school project and I'm running into an error that has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.