this is a conceptual question, but if i initialize a variable in c# as public will it be able to be used in the class as I want a variable "player1
" and a variable "player2
" where either could be one of the two (or more)
- Player
- Computer
Here is what i would like to know how I would do:
public class Game
{
//equivalent of initializing it here
public bool islogging;
public string[] log;
public int draws, round;
public Game(player p1, computer p2)
{
public player player1 = p1;
public computer player2 = p2;
}
//other overloads here...
...
}
trying this it doesn't work as the public keyword is rejected
public Game(player p1, player p2 )
{
public player player1, player2;
player player3 = p1;
player player4 = p2;
}