C
C#2y ago
Oli

✅ Need some help with classes

displayTeam and displapPlayer methods not working correctly
20 Replies
Oli
Oli2y 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
binstarjs
binstarjs2y 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
Oli2y 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
Oli2y ago
yeah thats what i want it to do but it doesnt do anything when i call it
binstarjs
binstarjs2y 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
binstarjs
binstarjs2y ago
either way, debug it first to make sure
Oli
Oli2y 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
Oli2y ago
oh yeah i just realised
binstarjs
binstarjs2y ago
no offense but this is the first time i heard such mweh probably i never socialize much with someone who codes before
Oli
Oli2y ago
im so shit at coding i didnt even realise that was a feature
Oli
Oli2y ago
it says cannot convert void to bool
Oli
Oli2y 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
More Posts
❔ Is there any way to use a proxy with TestServer?Looking at the integration/functional tests in the eShopOnContainers sample application https://gith❔ how can I add a custom analyzer to omnisharp(vscdoe's css extention)?I was having problems with auto complete while using unity, I tracked the problem down to this issue✅ I want to get duplicate items in my List (EF Core)I am trying to get a list of Cards from my database, and I am able to successfully get a List of Gui❔ AutoreseteventHello there, does the state of the Set() method of the object persists until another thread performs❔ Asp-all-route-data's initial value is changed with asp-route-*So, I have: ``` var parms = new Dictionary<String, String> { {"Nome", Nome.ToString() }, }; ``` ❔ Install .NET 6 Runtime to ARM64 Server, Packages Not found?E: Couldn't find any package by glob 'dotnet-runtime-7.0' E: Couldn't find any package by regex 'dot❔ How to make a method becomes available for all form?sorry I'm new at using method. I don't really understand about public method.Dictionary Implementation, but with custom class as keyI have implemented a dictionary like this code file Now `Dictionary.Add(10, "Washington");` will❔ BattleshipsHey! I'm making a battleships program. I am currently working on the boat placing and checking that Installing Docker and running ASP.NET project on Ubuntu Droplet led to ERR_CONNECTION_TIMED_OUT siteAnyone know what issue I had with Docker/NGINX when trying to run an ASP.NET site? I must say befor