Lektion 2
This commit is contained in:
parent
c00b7c1e38
commit
4c00f4785c
21
Lektion 2/Logische_Operatoren/Enthalten/Enthalten.pde
Normal file
21
Lektion 2/Logische_Operatoren/Enthalten/Enthalten.pde
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
float a = 10;
|
||||||
|
float b = 5;
|
||||||
|
float x = 6.3;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
|
||||||
|
// Check whether a is bigger b or the other way around
|
||||||
|
if ( a < b) {
|
||||||
|
if (a < x && x < b) {
|
||||||
|
println("x innerhalb");
|
||||||
|
} else {
|
||||||
|
println("x außerhalb");
|
||||||
|
}
|
||||||
|
} else if ( a > b) {
|
||||||
|
if (b < x && x < a) {
|
||||||
|
println("x innerhalb");
|
||||||
|
} else {
|
||||||
|
println("x außerhalb");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
// Ändere die Werte zum Testen
|
||||||
|
int alter = 33;
|
||||||
|
float note = 3.3;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
if (alter < 20 || alter > 60) {
|
||||||
|
println("lieber nicht");
|
||||||
|
} else if (note < 3.0) {
|
||||||
|
println("Einstellen!");
|
||||||
|
} else {
|
||||||
|
println("lieber nicht");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
float abschlussnote = 6;
|
||||||
|
int programmiererfahrung = 4;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
if (abschlussnote < 1.1 || (programmiererfahrung > 4 && abschlussnote < 3.1)) {
|
||||||
|
println("Eingestellt!");
|
||||||
|
} else if (abschlussnote < 2.1 || programmiererfahrung > 3) {
|
||||||
|
println("zum Gespräch einladen");
|
||||||
|
} else {
|
||||||
|
println("abgelehnt");
|
||||||
|
}
|
||||||
|
}
|
||||||
24
Lektion 2/Logische_Operatoren/Pulsieren/Pulsieren.pde
Normal file
24
Lektion 2/Logische_Operatoren/Pulsieren/Pulsieren.pde
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
int d = 50;
|
||||||
|
boolean touched = false;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
size(400,400);
|
||||||
|
}
|
||||||
|
void draw() {
|
||||||
|
background(255);
|
||||||
|
|
||||||
|
ellipse(width/2, height/2, d, d);
|
||||||
|
// increase and decrease ellipse
|
||||||
|
if (d < width && touched == false) {
|
||||||
|
d++;
|
||||||
|
} else if (d > 50 && touched == true) {
|
||||||
|
d--;
|
||||||
|
}
|
||||||
|
// switch between increasing and decreasing
|
||||||
|
if (touched == true && d == 50) {
|
||||||
|
touched = false;
|
||||||
|
}
|
||||||
|
if (d == width) {
|
||||||
|
touched = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user