Alice Community  

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

Reply
 
Thread Tools Display Modes
Creating a Boolean function to turn on and off a light bulb.
Old
gordee
Guest
 
Status:
Posts: n/a
Exclamation Creating a Boolean function to turn on and off a light bulb. - 09-28-2008, 05:15 PM

I already posted this question but nobody has answered and I really need help, so I figured I'd try again with a different name.

Here is my lab:

"Create a world with a lightbulb (lights) and a method turnOnOff that turns the lightbulb on/off depending on whether it is already on/off. When the lightbulb is on, its emissive color property has a value of yellow. When the lightbulb is off, the emissive color is black. Write a Boolean function isLightOn that returns true if he light bulb is on and false if it is off. When clicked, the lightbulb should turn on/off."

Here is what I have done so far:
1. Put the lightbulb into a room setting.
2. Wrote a method turnOnOff that looks like this:
lightbulb: set color to: black
lightbulb: set color to: yellow
3. Created a new event saying:
When mouse is clicked on 'lightbulb', do "lightbulb.turnOnOff"
(I do not know if step #3 was necessary it just seemed like something to do)
4. I started a new function calling it isLightOn. I pressed "Boolean" and now I'm completely stuck!

I need help getting the boolean function to work properly, and I need to know if I am supposed to put the event that I put in.

Thank you! Any help is appreciated! It is due Sunday night. I have a textbook but it really doesn't help me very much.
   
Reply With Quote
Old
Gillette Fusion
Guest
 
Status:
Posts: n/a
Default 09-28-2008, 07:51 PM

I'm a little confused on what you need to do . . .

- but Boolean is a fancy way of saying true or false (you probably knew that anyway). I think they want you to make the function something like ~

If (Light bulb = whatever) than
return True
Else
return False

Yeah, something like that.
   
Reply With Quote
Suggestion
Old
Confused
Guest
 
Status:
Posts: n/a
Default Suggestion - 10-02-2008, 09:46 PM

I had to do a similar project. Mine had to use a directional light, which was challenging. I set it up like this:

When mouse is clicked on light, do
if: (true) light color = yellow,
then: light set color to black
else: light set color to yellow

Hope this helps!
   
Reply With Quote
Reply

Tags
boolean, function, homework

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