c# - No overload for method '' takes 1 argument -
well, issue here says in title. i'm trying call bool value of player2 class tic tac toe-project have in school. think it's worth mentioning use "player player1, player2;" in beginning of form1.cs create 2 instances of class, player. i've read multiple posts on internet of them people trying call in more parameters providing. don't see how bool value of true or false more one.
thanks in advance.
one of buttons problem appears.
public void btn1_click(object sender, eventargs e) >{ { if (click1 == 0) { if (player2.getactive(true))//(turn == 0) { btn1.text = "x"; } else { >btn1.text = "o"; } //turn++; click1++; } else { btn1.text = btn1.text; } display(); checkit(); } } this player class.
` public class player { //characteristics string name; int points; bool active; //constructor public player() { points = 0; active = true; } //methods public void setname(string n) { name = n; } public string getname() { return name; } public void setpoints(int p) { points = p; } public int getpoints() { return points; } public void setactive(bool a) { active = a; } public bool getactive() { return active; }`
here,
if(player2.getactive(true)) you passing argument (true) method getactive. can see method declaration of getactive, takes no parameters:
public bool getactive() { return active; } // ↑ // empty parentheses i think mean here "if player2.getactive() true..." right? don't need specify value want if true, doing fine:
if (player2.getactive()) if want check if false, add ! before call negate result:
if (!player2.getactive())
Comments
Post a Comment