Konbanwa, minna-san! (In case you didn't know, konbanwa means "good evening", and minna means "everyone". The -san is added on, as the honorific. Sometimes, -sama is used as well.)
Okay, the Japanese lesson is over! *sweat* I sort of went off-track there, didn't I? *wince*
Mm...it's 10 : 30 P.M.
...I started this before ten, I swear! *sweat* I was just...writing something else...for an hour...
Anyways! Today we learnt about case statements. Or well, we reviewed it. Last night, I quickly read over Selection (II), so I didn't really have time to process everything. The only thing I really focussed on was label, and even then, I was still slightly confused.
In class, he clarified everything! So, it turns out that a case statment is basically a more sophisticated version of the if statement; used when there are many elsif options or objects following the keyword or. (Is that what you call them? ...I don't remember... Oh no...)
Er...for example, instead of writing:
if colour_choice = "blue" or colour_choice = "BLUE"
or colour_choice = "Blue" then
colour (blue)
elsif colour_choice = "red" or colour_choice = "RED"
or colour_choice = "Red" then
colour (red)
elsif colour_choice = "purple" or colour_choice = "PURPLE"
or colour_choice = "Purple" then
colour (purple)
end if
put "Thank you!"
You can use a case statement and write:
case colour_choice of
label "blue", "BLUE", "Blue" :
% blue text
colour (blue)
label "red", "RED", "Red" :
% red text
colour (red)
label "purple", "PURPLE", "Purple" :
% purple text
colour (purple)
end case
put "Thank you!"
See, isn't that much easier? *smile* Now that I look back at some of my Selection Assignments, I feel like groaning because it took so long to write if-ladders.
Well, I'm off to check if I finished my whole ATM Assignment yet or not. I think I did...but I'd rather not take the chance. Then again, if I forget today, I can always do it tomorrow, ne?
Which reminds me! Tomorrow is Take Your Kids to Work Day! I'm going to my mom's office, and it's sort of strange because...my mom is setting up "lessons" for me with everyone except her. She said "if one of them is too busy, then I'll show you what I do". Can you believe that? *cries*
Er, yes...I should get going now.
Ja ne, minna-san!
No comments:
Post a Comment