There's a lot of stuff wrong with this. Let's go through it step by step..
1) Both in
PlayerTurn(..)
and
ComputerTurn(..)
remove the
private
modifier from
private int num;
Access modifiers make no sense for local identifiers of a method, they're not visible outside the method anyway.
2) In
SwitchTurn(..)
you modify the variable
nowTurn
based on its current value. So you don't just want to pass it out of the method, you also want to pass the current value into the method. So you need a
ref
modifer instead of the
out
modifier:
public static void SwitchTurn(ref Boolean nowTurn)
And the call needs to be changed to:
SwitchTurn(ref turn);
3) Exactly the same goes for the
stoneLeft
parameter of
PlayerTurn(..)
and
ComputerTurn(..)
:
public static void PlayerTurn(ref int stoneLeft)
public static void ComputerTurn(ref int stoneLeft)
And the same for the calls:
PlayerTurn(ref stone);
ComputerTurn(ref stone);
Now the program at least compiles. I have no idea if it will do what you want and, honestly, I don't want to analyze this. Because there's another problem - not a syntactic problem but a style problem: All those
ref
-modifiers make it really a headache to follow the logic of your program. You should avoid
out
and
ref
unless you're very certain that they make sense. Sometimes they are useful and make sense, in this case, definitely not.
I would suggest you use a non-static class for your game logic. Create an instance of it in
Main(..)
and call a method on it to start the game. Almost all your variables would be class-instance-variables then and you wouldn't need those
ref
-modifiers.