alice-teacher How do I compare to paint colors in Alice 3?
Susan Rodger
rodger at cs.duke.edu
Mon Nov 25 11:08:30 EST 2013
I am using Alice 3 and trying to write a function to count how many
chickens in my array of chickens have been painted a particular color, say
yellow. This is easy to do in Alice 2 as one can compare two colors
in an "if statement". How would I compare colors in an if statement in
Alice 3?
I have an if statement in my function and I have two parameters, an array of
type flyers called "chickens" and a variable of type paint called
colorOfChicken. I want to go through the array and compare the paint color
of each chicken to the parameter colorOfChicken.
I already painted some of the chickens yellow and now want to call my
function to count how many yellow chickens there are.
I cannot figure out how to compare two paint colors to see if they are the
same. Each chicken has a function getPaint.
I can figure out how to use an if statement that works with numbers and strings.
What type does getPaint return, a string or a number? It doesn't seem
to be either. I tried converting
getPaint to a string but I can not drop in on top of the tostring function
and it is not a choice.
How does one compare paint colors in Alice 3?
Susan
=====================================================================
Susan H. Rodger, Professor of the Practice
Computer Science Dept. Box 90129, Duke University, Durham NC 27708-0129
Email: rodger at cs.duke.edu URL: http://www.cs.duke.edu/~rodger
Phone: (919)-660-6595 Fax: (919)-660-6519
More information about the alice-teachers
mailing list