Alice Community  

Go Back   Alice Community > General Discussion > The Lounge

Thread Tools Display Modes
ITSE-1429: Lab 2
Todd Thompson
Junior Member
Status: Offline
Posts: 12
Join Date: Jan 2012
Location: Mesquite, TX
Default ITSE-1429: Lab 2 - 03-02-2012, 06:16 AM

I had so much fun with this assignment that I did it twice. Okay, that's not entirely true: I completed the lab and then realized that I didn't use a loop statement to repeat the program. I had a string variable for the user to enter yes or no and originally controlled everything with If..Else statements like:
If again == yes first method
Else if again == Yes first method
Else if again -- YES first method
world.goodbye (a custom method)

While that worked, it was technically wrong since it wasn't a loop. The second time, I created a second variable called repeat that is set to TRUE if the string variable was yes, Yes, or YES.

If again == yes or again == Yes or again == YES
repeat set value to true
Loop 1 time
While repeat == true first method

repeat set value to false

This worked and it uses a loop so I feel better about it.
Reply With Quote
Status: Offline
Posts: 22
Join Date: Jan 2012
Default 03-03-2012, 03:31 PM

I almost wrote this one without using loops too, but quickly found a use for several of them.

I really enjoyed this lab too.
Reply With Quote
Junior Member
Status: Offline
Posts: 6
Join Date: Jan 2012
Default 03-03-2012, 05:13 PM

Hey Todd, it sounds like you have a solid grasp of the basic loop! I like how you built an artificial loop by calling " first method" repeatedly, but it is more "proper" I suppose to use a actual While loop instead.

I wound up using both types of loops in my program. I used a While loop for the main program and hooked it to a true/false variable that would be changed by the user at the end of each loop. If the user put in any of the three possible "yes" combos, it would stay true, otherwise the loop would break and the program end.

As for the ordinary Loop, I put the actual character spinning off in a sub-method, then fed it the users' input as a parameter. The character spins around fully once each time the loop runs, and the loop runs as many times as the user wants it to, then returns back to the main program.

Hope this helps someone, and congratulations on doing good so far y'all!
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright ©2021, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.