new example progs
This commit is contained in:
@ -0,0 +1,14 @@
|
||||
class WhileClass {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
int test = 1;
|
||||
test = 2;
|
||||
|
||||
{
|
||||
// Shadowing
|
||||
int test = 1;
|
||||
test = 2;
|
||||
}
|
||||
}
|
||||
}
|
23
src/test/resources/examplePrograms/Expr.stups
Normal file
23
src/test/resources/examplePrograms/Expr.stups
Normal file
@ -0,0 +1,23 @@
|
||||
class MyClass {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Integer
|
||||
a = 1 + 2;
|
||||
b = 1 + a * 2;
|
||||
c = (1 + 2) * b;
|
||||
d = (a - 5) / (2 - y) + 21;
|
||||
e = -1;
|
||||
f = 1 / -1 * -3 + (5 - -6);
|
||||
|
||||
// Boolean
|
||||
a = true;
|
||||
b = 5 < 6;
|
||||
c = !(5 < 6);
|
||||
d = (5 < 6) && !(6 < 5);
|
||||
e = 4 <= (4 + 1);
|
||||
f = "Hallo" == "Hallo";
|
||||
|
||||
// String
|
||||
a = "Hallo";
|
||||
}
|
||||
}
|
@ -11,5 +11,15 @@ class IfElseClass {
|
||||
}
|
||||
}
|
||||
System.out.println("x und y sind gleich gross.");
|
||||
|
||||
if (1 < 2)
|
||||
String s = "Ohne Klammern, da 1 Line.";
|
||||
|
||||
if (1 < 2)
|
||||
s = "If 1";
|
||||
if (2 < x)
|
||||
s = "If 2";
|
||||
else
|
||||
s = "Dangling else";
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,20 @@
|
||||
class WhileClass {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// int a = 1;
|
||||
// int b = 1;
|
||||
// int temp = 0;
|
||||
while (a < b) { // (a < 144)
|
||||
// temp = b;
|
||||
// b = a + b;
|
||||
// a = temp;
|
||||
// System.out.println(a);
|
||||
int a = 1;
|
||||
int b = 1;
|
||||
int temp = 0;
|
||||
|
||||
while (a < 144) {
|
||||
temp = b;
|
||||
b = a + b;
|
||||
a = temp;
|
||||
|
||||
System.out.println(a);
|
||||
}
|
||||
|
||||
while (b < 1)
|
||||
temp = 55;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
class WhileClass {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
int test = 1;
|
||||
int test = 1;
|
||||
int test = 1;
|
||||
int test = 1;
|
||||
int test = 1;
|
||||
int test = 1;
|
||||
int test = 1;
|
||||
int test = 1;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user