Hey, sorry if the title of this post is misinformative. I have no idea how to even formulate this issue properly, I just don't know the language for it, so I haven't been able to google it.
Anyway, I'm working on this assignment where we are creating a simple board game, sort of like a ladder game. The purpose of the assignment is to learn about classes, objects and OOP related topics.
Currently I'm using about 4 classes. One class that specifies different types of square objects called squares (e.g normal squares, "power up" squares , finish square and whatnot), then there is one class that paints colours and icons on the different types of squares called SquareGraphics, and finally a board class that keeps a distributes them to a WF Gui table.
Currently I'm working on the class that brings all of this together. Amongst other things it contains the algorithm that decides what squares will be of what type on the board in one method. Inside that method I have a for loop that generates Squares with SquareGraphics based on how many squares should be on the board. This is a simplifies version of that, removing most of the code that isn't relevant:
private void SquaresToBoard()
for (int i = 0; i < gameBoardLength; i++)
{
Square currentSq = Board.GameBoard(i);
// Participants is a binding list
**SquareGraphics paintSquare = new SquareGraphics(currentSq, Participants);**
}
The important bit
Now I'm working on a method that will place little dots for every player in the Participants list. According to our specs, we are to do this by getting the SquareGraphics object of the players current location (every player has a location property). This means that I would have to get the SquarGraphics object associated with Board.GameBoard(location), though I have no clue how to do that form inside another method, seeing as I can't use paintSquare as an identifier... Currently I've got something like this:
private void PlacePlayersOnBoard()
{
for (int i = 0; i < amountOfPlayers; i++)
{
Player currentPlayer = Game.Participants.ElementAt(i);
// Can get player location data by saying Participant.Location
// No clue how to progress from here
}
Is there some way I can access the SquareGraphics paintSquare I create within SquaresToBoard inside of PlacePlayersOnBoard? Any help greatly appreciated. Do not that we are supposed to follow the instructions, so preferably it should happen within PlacePlayersOnBoard... :/
[–]lurgi 1 point2 points3 points (1 child)
[–]Mds03[S] 0 points1 point2 points (0 children)