❔ Help Me with some C# Tests?

There's a few tests in this project that I'm stuck on, and could use some help
63 Replies
Pobiega
Pobiega2y ago
Do you expect someone to just hand you 5 solutions?
jcotton42
jcotton422y ago
@callmespriggy_8033 tell us what you've tried, and where you're stuck
CallMeSpriggy
CallMeSpriggyOP2y ago
I could try to get test 5 on my own (it's the separate for loop with a nested if loop that scares me) but test 6 is... I don't even know where to begin I haven't handled chars and strings all that much yet
Pobiega
Pobiega2y ago
Do you know what a char is?
CallMeSpriggy
CallMeSpriggyOP2y ago
No?? Really I just want to know where to begin characters like a, b, c
Pobiega
Pobiega2y ago
Correct they are actually numbers behind the scenes however so they can be incremented and decremented
CallMeSpriggy
CallMeSpriggyOP2y ago
,,,,huh. so just. treat them like numbers under a different name?
jcotton42
jcotton422y ago
'a' + 1 is 'b'
CallMeSpriggy
CallMeSpriggyOP2y ago
that... makes sense lemme try something I don't think I have this right I feel like I should decalre smth
Pobiega
Pobiega2y ago
Show us what you tried
CallMeSpriggy
CallMeSpriggyOP2y ago
CallMeSpriggy
CallMeSpriggyOP2y ago
I feel like I'm on the right track
Pobiega
Pobiega2y ago
Sure. Your expected return type is string thou so what must we do, once we figured out how to get the char?
CallMeSpriggy
CallMeSpriggyOP2y ago
add 1 to it unless it gets to number?
Pobiega
Pobiega2y ago
that just gets us a bunch of char we need to end up with a string at the end, made up of all the chars we "made"
CallMeSpriggy
CallMeSpriggyOP2y ago
add it to a string?
Pobiega
Pobiega2y ago
That works
CallMeSpriggy
CallMeSpriggyOP2y ago
...how would I do that?
Pobiega
Pobiega2y ago
declare an empty string variable outside your loop
CallMeSpriggy
CallMeSpriggyOP2y ago
what do I set it equal to
Pobiega
Pobiega2y ago
what do you think?
CallMeSpriggy
CallMeSpriggyOP2y ago
starter?
Pobiega
Pobiega2y ago
question: did you write the // for + nested while loops comment?
CallMeSpriggy
CallMeSpriggyOP2y ago
yea
Pobiega
Pobiega2y ago
okay you can safely remove that 😄 you need a for loop, but no nested whiles
CallMeSpriggy
CallMeSpriggyOP2y ago
oh thank god
Pobiega
Pobiega2y ago
do you understand what a for loop does and how it works?
CallMeSpriggy
CallMeSpriggyOP2y ago
not confidently, but yea
Pobiega
Pobiega2y ago
okay. can you walk me through what your current for loop does, and what its condition is?
CallMeSpriggy
CallMeSpriggyOP2y ago
currently, it doesn't do anything yet, but it's supposed to take the char given to it, add 1 to it to form a string of letters from starter onwards using number, and return that string
Pobiega
Pobiega2y ago
no thats the entire method Im asking about your for loop
CallMeSpriggy
CallMeSpriggyOP2y ago
it hmm the condition is number, I think that's what tells it when to stop rn it doesn't do anything bc I don't have anything in it
Pobiega
Pobiega2y ago
well, look at that condition c < number
CallMeSpriggy
CallMeSpriggyOP2y ago
should it be <=
Pobiega
Pobiega2y ago
no, its not the comparison but if c has the value of starter
CallMeSpriggy
CallMeSpriggyOP2y ago
than it owuld be more than number?
Pobiega
Pobiega2y ago
yes
MODiX
MODiX2y ago
pobiega#0000
REPL Result: Success
(int)'A'
(int)'A'
Result: int
65
65
Compile: 428.249ms | Execution: 23.177ms | React with ❌ to remove this embed.
Pobiega
Pobiega2y ago
as we cna see here, 'A' is 65
CallMeSpriggy
CallMeSpriggyOP2y ago
so it should be >
Pobiega
Pobiega2y ago
no but if number is 5... and Ais 65...
CallMeSpriggy
CallMeSpriggyOP2y ago
then it wouldn't work
Pobiega
Pobiega2y ago
because number is too low, right?
CallMeSpriggy
CallMeSpriggyOP2y ago
yea
Pobiega
Pobiega2y ago
what if we increased number by something, in the comparison?
CallMeSpriggy
CallMeSpriggyOP2y ago
it would match?
Pobiega
Pobiega2y ago
what could we reasonably increase number by
CallMeSpriggy
CallMeSpriggyOP2y ago
...starter?
Pobiega
Pobiega2y ago
yes!
CallMeSpriggy
CallMeSpriggyOP2y ago
so I put number + starter in the loop body?
Pobiega
Pobiega2y ago
in the loop condition for (char c = starter; c < starter + number; c++) this way, c starts at starter and will increase gradually number times
CallMeSpriggy
CallMeSpriggyOP2y ago
okay so then how to I get the chars in the string we delcared actually, what do I set that empty string to ""?
Pobiega
Pobiega2y ago
"" is indeed an empty string
CallMeSpriggy
CallMeSpriggyOP2y ago
ah so do I set String equal to starter in the loop body?
Pobiega
Pobiega2y ago
well no
CallMeSpriggy
CallMeSpriggyOP2y ago
c?
Pobiega
Pobiega2y ago
you shouldnt use starter anymore c !
CallMeSpriggy
CallMeSpriggyOP2y ago
it auto-filled in with String = String + c oh my god it wokrs HA this is like my thrid time trying to tackle this lab and this is the farthest I've ever gotten
Pobiega
Pobiega2y ago
id prefer value += c; where value is your string variable but it does the same thing, just looks better
CallMeSpriggy
CallMeSpriggyOP2y ago
,,yeah, that does look better wait, do I even need a nested while or if loop for 7 & 8, then?
Pobiega
Pobiega2y ago
I have not read the description of either of those yet
CallMeSpriggy
CallMeSpriggyOP2y ago
I think I might take a break, actually- it's late and my brain is starting to get mushy lmao thanks for your help! I really do appreciate it
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