✅ Need some help with classes
displayTeam and displapPlayer methods not working correctly
20 Replies
class Player
{
private string PName;
private int PAtk;
private int PDef;
public string displayPlayer()
{
return PName + " " + PAtk + " " + PDef;
}
public void setName(string PName)
{
this.PName = PName;
}
public void setAtk(int PAtk)
{
this.PAtk = PAtk;
}
public void setDef(int PDef)
{
this.PDef = PDef;
}
}
Define "not working correctly"
As a side note, that's some very Java-looking C# you have there
What with setter methods and
camelCase
namesi see no definitions for both displayTeam and displapPlayer unless my eyes read the code too fast and miss it. Lack of context, no explanation, nothing, just vague
$detail
$details
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
oh yeah i forgot to say they dont output anything
Well I can only see the
displayPlayer()
method, not the other one
And it doesn't print anything to the console if that's what you mean
It only returns a stringyeah thats what i want it to do but it doesnt do anything when i call it
you probably forgot to use the returned value, e.g not printing it to the console
I guess place some breakpoints, start up the debugger, and see what the values are
either way, debug it first to make sure
ngl i dont think ive ever used the debugger
$debug
Tutorial: Debug C# code - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
oh yeah i just realised
no offense but this is the first time i heard such probably i never socialize much with someone who codes before
im so shit at coding
i didnt even realise that was a feature
it says cannot convert void to bool
oh wait i dont have a return
thats probably why
yeah i should probably start doing that when asking for help
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.