Code
//yeah i can't get this to work at all...
void setup() {
size(300,300);
smooth();
background(255);
drawRandomLine();
color cpotato = color (200,200,100);
drawpotato(averageofthreenumbers, cpotato, isthemonthgreaterthanthehour);
}
void drawRandomLine() {
float x1 = random (0,10);
float x2 = random (0,50);
float y1 = random (0,80);
float y2 = random (0,30);
line(x1, y1, x2, y2);
}
float getthelargeroftworandomnumbers(){
float number1 = random (0,50);
float number2 = random (0,50);
float larger = max (number1, number2);
return larger;
}
boolean isthemonthgreaterthanthehour(){
int imonth = month();
int ihour = hour();
boolean greater = imonth > ihour;
return greater;
}
float averageofthreenumbers(float number1, float number2, float number3){
float avg = ((number1 + number2 + number3)/3);
return avg;
}
void eye(int x, int y){
fill(255);
strokeWeight(2);
ellipse(x,y,20,30);
}
void mustache(int x, int y){
fill (40,46,50);
noStroke();
rect((width/2)-10, (height/2)-10, 20,10);
}
void drawpotato(int averageofthreenumbers, color cpotato, boolean isthemonthgreaterthanthehour){
noStroke();
smooth();
fill(cpotato);
ellipse(width/2, height/2, 125,175);
if (isthemonthgreaterthanthehour=true){
mustache (width/2, height/1.75);
}
for (int i=0; i<n; i=i+1){
eye(random(width/2)-20, random(width/2)+20);
eye(random(width/2)-20, random(width/2)+20);
}
}
}
0401 - Function review: All manner of functions
Statement:This assignment asks you to create and use several functions. In addition to defining the code for the functions themselves, please also prove that they work correctly by calling/invoking them from your setup function. If you test a function by printing a result, make sure that your print command is not in the code of the function itself, but in the code which calls/invokes your custom function.
Broadly speaking, your code will look approximately like the following:
void setup(){
doSomething();
println( doThingThatReturnsTrue() );
}
void doSomething(){
// what goes here?
}
boolean doThingThatReturnsTrue(){
return true;
}
hide statement