Endabgabe Test Klassen
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
This commit is contained in:
parent
084808c3ab
commit
91552ad147
25
src/test/resources/input/endabgabeTests/Car.java
Normal file
25
src/test/resources/input/endabgabeTests/Car.java
Normal 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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
11
src/test/resources/input/endabgabeTests/Person.java
Normal file
11
src/test/resources/input/endabgabeTests/Person.java
Normal file
@ -0,0 +1,11 @@
|
||||
public class Person {
|
||||
private int age;
|
||||
|
||||
public Person(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return this.age;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user