Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
need help with IF and Else
Old
thetrippster
Guest
 
Status:
Posts: n/a
Default need help with IF and Else - 10-20-2006, 09:58 AM

k here is wat i have to do,

(a) Modify the zues world to make each philosopher say something different when clicked.
Euripides says, "come on guys, I want to take a bath."
PLato says, "I call it Play Doe" and then extends his right hand to show the other philosphers his play Doe.
Homer says, "By my calculations, pretzels are the optimum solid food."
Socrates says, "Like sands in the hour galss, so are the days of our lives."

Use and If statement to determine which philosopher was clicked.

(b) Modify the Zues world so that if homer gets clicked and zapped by thunderbolt, he falls over, says "d'oh", and then stands back up again(instead of turning color). Allow repeated clicking on homer, which should result in his repeated falling down and getting back up.

Can any one help me with this? i have to use a previous project to do this project i have attached it below. i need some one to explain hownto do the IF and ELSE part for me. im clueless on how they work, thanks to the book on the last one showed exactly what to input for the if and else.

plz help
Attached Files
File Type: a2w Zeus hates everybody.a2w (2.95 MB, 429 views)
   
Reply With Quote
Some clues.
Old
DrJim
Guest
 
Status:
Posts: n/a
Lightbulb Some clues. - 10-20-2006, 01:08 PM

I'd ask for more detail on what part of the problem is giving you difficulty, but "clueless" is pretty inclusive . As a start, note that the problem mixes a conditional statements (If/Else, see http://en.wikipedia.org/wiki/If_statement ) and simple but long Boolean expressions (… OR … OR …., see http://en.wikipedia.org/wiki/Boolean_expression ).

The key here is to look at the If statement first and make sure you know what happens if it is true and alternately what happens if it is false (the Else part). Then look at the test part of the if statement and see if evaluating it does what you want (i.e., it is true if you have clicked on any philosopher). Be careful here - the computer is very literal.

If everything is fine with the first If/Else, then add another to test further - in this case test for Homer - do one thing if the test condition is true and another if it is false.

Hope this gives you a start.
   
Reply With Quote
Old
lanceA
Guest
 
Status:
Posts: n/a
Default 10-20-2006, 05:20 PM

k here is wat "u" have to do,

Firstly, the assignment you are trying to do is Exercise 6.1, page 259 of the old Programming with Alice book (this predates the Beta Alice book, which predated the published Learning to Program With Alice book). Anyway, if you have that 'book' you may wish to review Sections 6.1 - 6.3 (starting on page 235) to get a better understanding of the If/Else construct. There's even some code shown which can help you with Exercise 6.1 to have the ". . . appropriate philosopher philosophize."

[Edit] Part (b) of your question is obviously Exercise 6.2 from the unpublished 'book'. But again if you re-read the document it will provide you with the needed information.

You mentioned in your post that you "had the book" - "......thanks to the book on the last one showed exactly what to input for the if and else."[sic], so I am assuming the page numbers I provide are relevant to you.


Good luck.

Last edited by lanceA; 10-20-2006 at 07:55 PM.
   
Reply With Quote
Alternate page reference.
Old
DrJim
Guest
 
Status:
Posts: n/a
Arrow Alternate page reference. - 10-21-2006, 11:29 AM

The question looked to me to be taken verbatim (except for typo's) from exercise 6 on page 173 of the published Dunn, et al text. If so, the relevant pages are pp. 154-167. Be prepared to re-read them several times as you go along - there's a lot of detail in those few pages.
   
Reply With Quote
Old
lanceA
Guest
 
Status:
Posts: n/a
Default 10-22-2006, 02:57 PM

You're correct. It's in both 'books'.
   
Reply With Quote
Old
Shadow Sovereign
Guest
 
Status:
Posts: n/a
Arrow 10-31-2006, 09:47 AM

Tripp, your spelling is atrocious...
   
Reply With Quote
Reply

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 ©2022, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.