0
Can someone help me out with my code its saying complication error.
14 Réponses
+ 1
You have a bunch of coding errors. Your method doesn't return a value, yet you attempt to assign it to a variable. You're missing tons of }. RandomNumbers.sayNumber() is invalid so delete it.
+ 1
Line 29 remove }
0
I fixed the { } now it says there is 2 errors I can't seem to fix them
https://code.sololearn.com/c5BL4rb1UACd/?ref=app
0
I removed line 29 } now there's a brand new error Ive tried multiple things to fix it but it won't go away
https://code.sololearn.com/c5BL4rb1UACd/?ref=app
0
You are trying too much at once. I suggest you comment out most of the code and work on a piece at a time. The easiest way to build a program as a beginner is baby steps. Code a little piece and get it working. Then, add the next thing to build on it. Comment out all cases in the switch and work on getting case 2 working. You still haven't addressed all of the stuff in my first comment. Your break statement in your cases is nested within an if statement so it won't stop execution from continuing into the next case.
0
I took your advice on coding little by little at a time and created a exact copy of the other code but shorter this time. I'm confused on what I should change RandomNumbers.sayNumber() with.
https://code.sololearn.com/cZvdvbcnXevR/?ref=app
0
I made it public what should I use instead of main?
0
I created a different code could you help me on it?
https://code.sololearn.com/cXWWzSFpUO6y/?ref=app
0
You're still trying too much at once. You are referencing your arrays incorrectly.
string[] a;
int b;
string n = b[a];
It should be a[b]. a is defined as the array, not b.
0
wait why would I change the variable 'troop' to 'n' in string?
0
I got it to compile. Still have problems with commented out code at line 171.
https://code.sololearn.com/cN2SVUiRDO1L/?ref=app
0
this is awesome but i noticed u made part of the code on lines 174 - 177 a comment, I was wondering if there was a way to make it to where the user is able to choose between 2 random troops?
- 1
Make it public so I can comment on it. Your sayNumber method generates a random number and displays it. It doesn't return anything so main can't use it.
- 1
You wouldn't. I was just giving an example.