Endabgabe Test Klassen
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled

This commit is contained in:
i22035 2024-07-03 23:04:07 +02:00
parent 084808c3ab
commit 91552ad147
3 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,25 @@
public class Main {
public static void main(String[] args) {
Car myCar = new Car(2020);
int tires = 0;
int year = myCar.getYear();
if (year == 2020) {
tires = 4;
} else {
tires = 2;
}
}
}
class Car {
private int year;
public Car(int year) {
this.year = year;
}
public int getYear() {
return this.year;
}
}

View File

@ -0,0 +1,36 @@
public class ControlStructures {
public int sum(int a, int b) {
return a + b;
}
public cahr checkNumber(int num) {
if (num > 0) {
return "p";
} else if (num < 0) {
return "n";
} else {
return "z";
}
}
public void printNumbersUpTo(int limit) {
int even = 0;
int uneven = 0;
int i = 0;
while (i < limit) {
if (i % 2 == 0) {
even++;
} else {
uneven = uneven + 1;
}
i++;
}
}
public static void main(String[] args) {
ControlStructures cs = new ControlStructures();
cs.printNumbersUpTo(5);
int result = cs.sum(5, 5);
}
}

View File

@ -0,0 +1,11 @@
public class Person {
private int age;
public Person(int age) {
this.age = age;
}
public int getAge() {
return this.age;
}
}