add Demo files for easier testing

This commit is contained in:
simon 2024-07-05 16:38:24 +02:00
parent c56d0facca
commit 19b7f85d8a
6 changed files with 75 additions and 0 deletions

12
demo/Fibonacci.java Normal file
View File

@ -0,0 +1,12 @@
public class Fibonacci {
public static void main(String[] args) {
int a = 0;
int b = 1;
for (int i = 0; i < 20; i++) {
print(a);
int temp = a;
a = b;
b = temp + b;
}
}
}

26
demo/PrintNumbers.java Normal file
View File

@ -0,0 +1,26 @@
public class PrintNumbers {
public int start;
public int max;
public PrintNumbers(int start, int max) {
this.start = start;
this.max = max;
}
public void start() {
do {
this.start += 1;
if(this.start == 6) {
continue;
}
if(this.start >= 12) {
break;
}
print(this.start);
} while (this.start <= this.max);
}
public static void main(String[] args) {
PrintNumbers p = new PrintNumbers(0, 12);
p.start();
}
}

20
demo/Test.java Normal file
View File

@ -0,0 +1,20 @@
public class Test {
public static void main(String[] args) {
print(true); // prints true
print('a'); // prints 'a'
print(5); // prints 5
boolean b = true;
char c = 'x';
int i = 3;
print(b); // prints true
print(c); // prints x
print(i); // prints 3
boolean result = !b && true;
print(result); // prints false
print(c); // prints {x}
}
}

11
demo/Test1.java Normal file
View File

@ -0,0 +1,11 @@
public class Test1 {
public void printResult(int a, int b) {
Test2 t = new Test2();
print(t.multiply(a, b));
}
public static void main(String[] args) {
Test1 t = new Test1();
t.printResult(12, 8);
}
}

6
demo/Test2.java Normal file
View File

@ -0,0 +1,6 @@
public class Test2 {
public int multiply(int a, int b) {
return a * b;
}
}

BIN
demo/compiler.jar Normal file

Binary file not shown.