Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions Documentation2.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
# Name:
# Name:void merryChristmas

## Examples:
Insert examples here.
void merryChristmas() {
background(0);
fill(255, 0, 0);
textSize(50);
text("Merry Christmas!", mouseX, mouseY);
if (mouseX>width/2-100) {
return;
}
fill(0, 255, 0);
text("Feliz Navidad!", mouseX, mouseY+100);

## Description:
Insert description here
the mouse will control where the user sees both Merry Christmas and Feliz Navidad
on the screen. however, when the mouse's X position is greater than half the width of the
screen, then the "Feliz Navidad" goes away.

## Syntax:
Demonstrate syntax here
void datatype(){
background(int, int);
fill(r,g,b);
textSize(int);
text("text", x,y);
if(something){
return();
}

fill(r,g,b);
text("text", x,y);
}

##Parameters:
Name and describe parameters here
none

##Returns:
What type of data does it return?
##Returns:it gets rid of the "Feliz Navidad" after the mouse's X location
is greater than half the width
no numerical data is returned

##Other notes:
Anything else?
32 changes: 32 additions & 0 deletions functionsChallenge/functionsChallenge.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
void setup() {//runs once
size(600, 600);
}

void draw() {//runs in a loop
println(square(25)); //the program will find the square root of a number
merryChristmas();//the function will run in a loop
println(quadratic(1, 5, 6));//the answers will be printed
}

float square(int num) {//initialize the function
float result=sqrt(num); //to find the square root of the number
return result;//returns the result, the square root
}
float[] quadratic(float a, float b, float c) {//function is float, because it will return a value
float[] answers = new float[2];//the quadratic formula looks for two answers
answers[0]=(-b + sqrt( b*b - 4*a*c)) / (2*a);//the first array will look for the first x
answers[1]=(-b - sqrt( b*b - 4*a*c)) / (2*a);//will calculate the second x
return answers;//will then give both x's
}

void merryChristmas() {//the function, merryChristmas, is initialized
background(0);
fill(255, 0, 0);//the color of the first line of text
textSize(50);
text("Merry Christmas!", mouseX, mouseY);//what the first line of text will say
if (mouseX>width/2-100) {//when the x position of the mouse is greater than 1/2 the width, then the second line will disappear
return;//will return to the original first line of text depending where the mouse is positioned
}
fill(0, 255, 0);
text("Feliz Navidad!", mouseX, mouseY+100);//the second line of text, which disappears according to the position of the mouse
}
43 changes: 43 additions & 0 deletions merryChristmas.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Name:void merryChristmas

## Examples:
void merryChristmas() {
background(0);
fill(255, 0, 0);
textSize(50);
text("Merry Christmas!", mouseX, mouseY);
if (mouseX>width/2-100) {
return;
}
fill(0, 255, 0);
text("Feliz Navidad!", mouseX, mouseY+100);

## Description:
the mouse will control where the user sees both Merry Christmas and Feliz Navidad
on the screen. however, when the mouse's X position is greater than half the width of the
screen, then the "Feliz Navidad" goes away.

## Syntax:
void datatype(){
background(int, int);
fill(r,g,b);
textSize(int);
text("text", x,y);
if(something){
return();
}

fill(r,g,b);
text("text", x,y);
}

##Parameters:
Name and describe parameters here
none

##Returns:it gets rid of the "Feliz Navidad" after the mouse's X location
is greater than half the width
no numerical data is returned

##Other notes:
Anything else?
30 changes: 30 additions & 0 deletions quadratic.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Name: float [] quadratic

## Examples:
float[] quadratic(float a, float b, float c) {
float[] answers = new float[2];
answers[0]=(-b + sqrt( b*b - 4*a*c)) / (2*a);
answers[1]=(-b - sqrt( b*b - 4*a*c)) / (2*a);
return answers;

## Description:
the function was created to calculate the zeros of the equation, chosen by user, by using the
quadratic formula. it is an array, since the formula will provide two answers.
the function is a float, since it will return a value, and then set up with three float parameters

## Syntax:
datatype[]var( float var, float var, float var){
datatype[]var= new datatype[n];
var[n]=value;
return var;

##Parameters:
float a,b,c= according to equation chosen by user in void draw
these are the coefficients in the quadratic formula, and also serve as the variables
in the function

##Returns:
the zeros of the equation (value)

##Other notes:
Anything else?
28 changes: 28 additions & 0 deletions square().txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Name: Desiree Armas

## Examples:
variables
num=25;
the program will then find the square root of 25

## Description:
the user gets to choose a number
the program will then find the sqaure root of that number
( in order for the syntax to be user-friendly,
I inserted a variable , num and result, instead of an actual value)

## Syntax:
void draw(){
println(square(25));//the user chose this number, represented in the below code (num)
float square(int num) {
float result=sqrt(num);// this finds the square root of the number, represented by (result)
return result;//returns the result

##Parameters:
integers( int num)

##Returns:
the square root of a chosen number

##Other notes:
Anything else?
28 changes: 28 additions & 0 deletions square()function.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Name: float square

## Examples:
variables
num=25;
the program will then find the square root of 25

## Description:
the user gets to choose a number
the program will then find the sqaure root of that number
( in order for the syntax to be user-friendly,
I inserted a variable , num and result, instead of an actual value)

## Syntax:
void draw(){
println(square(25));//the user chose this number, represented in the below code (num)
float square(int num) {
float result=sqrt(num);// this finds the square root of the number, represented by (result)
return result;//returns the result

##Parameters:
integers( int num)

##Returns:
the square root of a chosen number

##Other notes:
Anything else?