Question check in another method

Exploit

New member
Joined
May 28, 2015
Messages
2
Programming Experience
Beginner
Hello everyone.
I made method(1) for checking if my pieces in board game are in goal ,base and ordered if in goal.
Thing i don't know how to do is how to check in another method(2) is that bool VALUE property from method(1) true or false.


method(1)
C#:
   public bool isAllPiecesInBaseOrGoalOrdered(List<int> goalPositions,List<int> basePositions,List<int> piecePositions )
        {
            List<int> piecesOnGoal =new List<int>();
            List<int> piecesOnBase = new List<int>();
            bool value = false;






            for (int i = 0; i < 4; i++)
            {


                if (goalPositions.Contains(piecePositions[i]))
                {
                    piecesOnGoal.Add(i);


                    if (basePositions.Contains(piecePositions[i]))
                        {
                            piecesOnBase.Add(i);
                        }
                }
                else
                    value = false;


                
            }
            if (piecesOnBase.Count + piecesOnGoal.Count == 4)
            {
                value = true;
            }


          
            for (int i = 3; i >= 0; i++)
            {
                if (piecesOnGoal.Count > 0)
                    if (piecesOnGoal.Contains(goalPositions[i]))
                        piecesOnGoal.Remove(goalPositions[i]);
                    else
                        value=false;
                   
            }








            return value;
        
        }


method(2) this is where i am stuck need to check if Value from isAllPiecesInBaseOrGoalOrdered is true or false
C#:
public void resetAmountOfThrows()
        {
            if (isAllPiecesInBaseOrGoalOrdered()) //here i get error
                              //no overload for method 'isAllPiecesInBaseOrGoalOrdered' takes 0 arguments
                numberOfThrows = 3;


            else
                numberOfThrows = 1;
        }




Any help is appreciated.
Sorry for bad English.
Thank you in advance.
 
Of course you get an error. You have declared your `isAllPiecesInBaseOrGoalOrdered` method as requiring three List<int> references to be passed to it when you called and you aren't passing anything at all when you call it. If you declare a method with parameters then you have to pass arguments to those parameters when you call it.

By the way, while what conventions you use is up to you, it is almost universally accepted that C# method names begin with an upper-case letter so I suggest that you do the same.
 
Back
Top Bottom