C
C#13mo ago
CallMeSpriggy

❔ 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
Pobiega13mo ago
Do you expect someone to just hand you 5 solutions?
jcotton42
jcotton4213mo ago
@callmespriggy_8033 tell us what you've tried, and where you're stuck
CallMeSpriggy
CallMeSpriggy13mo 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
Pobiega13mo ago
Do you know what a char is?
CallMeSpriggy
CallMeSpriggy13mo ago
No?? Really I just want to know where to begin characters like a, b, c
Pobiega
Pobiega13mo ago
Correct they are actually numbers behind the scenes however so they can be incremented and decremented
CallMeSpriggy
CallMeSpriggy13mo ago
,,,,huh. so just. treat them like numbers under a different name?
jcotton42
jcotton4213mo ago
'a' + 1 is 'b'
CallMeSpriggy
CallMeSpriggy13mo ago
that... makes sense lemme try something I don't think I have this right I feel like I should decalre smth
Pobiega
Pobiega13mo ago
Show us what you tried
CallMeSpriggy
CallMeSpriggy13mo ago
CallMeSpriggy
CallMeSpriggy13mo ago
I feel like I'm on the right track
Pobiega
Pobiega13mo ago
Sure. Your expected return type is string thou so what must we do, once we figured out how to get the char?
CallMeSpriggy
CallMeSpriggy13mo ago
add 1 to it unless it gets to number?
Pobiega
Pobiega13mo 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
CallMeSpriggy13mo ago
add it to a string?
Pobiega
Pobiega13mo ago
That works
CallMeSpriggy
CallMeSpriggy13mo ago
...how would I do that?
Pobiega
Pobiega13mo ago
declare an empty string variable outside your loop
CallMeSpriggy
CallMeSpriggy13mo ago
what do I set it equal to
Pobiega
Pobiega13mo ago
what do you think?
CallMeSpriggy
CallMeSpriggy13mo ago
starter?
Pobiega
Pobiega13mo ago
question: did you write the // for + nested while loops comment?
CallMeSpriggy
CallMeSpriggy13mo ago
yea
Pobiega
Pobiega13mo ago
okay you can safely remove that 😄 you need a for loop, but no nested whiles
CallMeSpriggy
CallMeSpriggy13mo ago
oh thank god
Pobiega
Pobiega13mo ago
do you understand what a for loop does and how it works?
CallMeSpriggy
CallMeSpriggy13mo ago
not confidently, but yea
Pobiega
Pobiega13mo ago
okay. can you walk me through what your current for loop does, and what its condition is?
CallMeSpriggy
CallMeSpriggy13mo 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
Pobiega13mo ago
no thats the entire method Im asking about your for loop
CallMeSpriggy
CallMeSpriggy13mo 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
Pobiega13mo ago
well, look at that condition c < number
CallMeSpriggy
CallMeSpriggy13mo ago
should it be <=
Pobiega
Pobiega13mo ago
no, its not the comparison but if c has the value of starter
CallMeSpriggy
CallMeSpriggy13mo ago
than it owuld be more than number?
Pobiega
Pobiega13mo ago
yes
MODiX
MODiX13mo 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
Pobiega13mo ago
as we cna see here, 'A' is 65
CallMeSpriggy
CallMeSpriggy13mo ago
so it should be >
Pobiega
Pobiega13mo ago
no but if number is 5... and Ais 65...
CallMeSpriggy
CallMeSpriggy13mo ago
then it wouldn't work
Pobiega
Pobiega13mo ago
because number is too low, right?
CallMeSpriggy
CallMeSpriggy13mo ago
yea
Pobiega
Pobiega13mo ago
what if we increased number by something, in the comparison?
CallMeSpriggy
CallMeSpriggy13mo ago
it would match?
Pobiega
Pobiega13mo ago
what could we reasonably increase number by
CallMeSpriggy
CallMeSpriggy13mo ago
...starter?
Pobiega
Pobiega13mo ago
yes!
CallMeSpriggy
CallMeSpriggy13mo ago
so I put number + starter in the loop body?
Pobiega
Pobiega13mo 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
CallMeSpriggy13mo 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
Pobiega13mo ago
"" is indeed an empty string
CallMeSpriggy
CallMeSpriggy13mo ago
ah so do I set String equal to starter in the loop body?
Pobiega
Pobiega13mo ago
well no
CallMeSpriggy
CallMeSpriggy13mo ago
c?
Pobiega
Pobiega13mo ago
you shouldnt use starter anymore c !
CallMeSpriggy
CallMeSpriggy13mo 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
Pobiega13mo ago
id prefer value += c; where value is your string variable but it does the same thing, just looks better
CallMeSpriggy
CallMeSpriggy13mo ago
,,yeah, that does look better wait, do I even need a nested while or if loop for 7 & 8, then?
Pobiega
Pobiega13mo ago
I have not read the description of either of those yet
CallMeSpriggy
CallMeSpriggy13mo 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
Accord13mo 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