Directions: We want to generate a custom dot for our image-scatter-plot
, such that every species gets a unique color. Write a function called species-dot
, which takes in a Row from the animals table and returns a solid, 5px circle using black for dog, orange for cat, pink for rabbit, red for tarantula, green for lizard and blue for snail.
Contract and Purpose Statement |
Every contract has three parts…
species-dot::Row->Image
Consumes an animal and produces a solid 5-pixel dot, black if dog, orange if cat, pink if rabbit, red if tarantula, green if lizard and blue if snail.
Examples |
Write some examples, then circle and label what changes…
examples:
__species-dot (dog-row)__ is circle(5, "solid", "black")
__species-dot (cat-row)__ is circle(5, "solid", "orange")
__species-dot (rabbit-row)__ is circle(5, "solid", "pink")
__species-dot (tarantula-row)__ is circle(5, "solid", "red")
__species-dot (lizard-row)__ is circle(5, "solid", "green")
__species-dot (snail-row)__ is circle(5, "solid", "blue")
end
Definition |
Write the definition, giving variable names to all your input values…
fun species-dot(r):
__if (r["species"] == "dog"): circle(5, "solid", "black")
__else if (r["species"] == "cat"): circle(5, "solid", "orange")
__else if (r["species"] == "rabbit"): circle(5, "solid", "pink")
__else if (r["species"] == "tarantula"): circle(5, "solid", "red")
__else if (r["species"] == "lizard"): circle(5, "solid", "green")
__else if (r["species"] == "snail"): circle(5, "solid", "blue")
__end
end
These materials were developed partly through support of the National Science Foundation,
(awards 1042210, 1535276, 1648684, and 1738598).
Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.