C
C#2y ago
Oli

✅ Need some help with classes

displayTeam and displapPlayer methods not working correctly
20 Replies
Oli
OliOP2y ago
Oli
OliOP2y ago
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; } }
Angius
Angius2y ago
Define "not working correctly" As a side note, that's some very Java-looking C# you have there What with setter methods and camelCase names
Bin
Bin2y ago
i 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
MODiX
MODiX2y ago
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)
Oli
OliOP2y ago
oh yeah i forgot to say they dont output anything
Angius
Angius2y ago
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 string
Oli
OliOP2y ago
yeah thats what i want it to do but it doesnt do anything when i call it
Bin
Bin2y ago
you probably forgot to use the returned value, e.g not printing it to the console
Angius
Angius2y ago
I guess place some breakpoints, start up the debugger, and see what the values are
Bin
Bin2y ago
either way, debug it first to make sure
Oli
OliOP2y ago
ngl i dont think ive ever used the debugger
Angius
Angius2y ago
$debug
MODiX
MODiX2y ago
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.
Oli
OliOP2y ago
oh yeah i just realised
Bin
Bin2y ago
no offense but this is the first time i heard such mweh probably i never socialize much with someone who codes before
Oli
OliOP2y ago
im so shit at coding i didnt even realise that was a feature
Oli
OliOP2y ago
it says cannot convert void to bool
Oli
OliOP2y ago
oh wait i dont have a return thats probably why yeah i should probably start doing that when asking for help
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server