Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging of Main and Julians_Prototypen #2

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/build-grade-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Build Gradle project

on:
push:

jobs:
build-gradle-project:
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v3
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: gradle Test
run: ./gradlew test
- name: Run build with Gradle Wrapper
run: ./gradlew build
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions app/src/main/java/hsw/gradle/template/Addition.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package hsw.gradle.template;

public class Addition {
public int add(int a, int b) {
return a + b;
}
public double add(int a, double b) {
return a + b;
}
public double add(double a, int b) {
return a + b;
}
public double add(double a, double b) {
return a + b;
}
}
78 changes: 73 additions & 5 deletions app/src/main/java/hsw/gradle/template/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,79 @@
package hsw.gradle.template;

public class App {
public String getGreeting() {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
System.out.println("Hello and welcome!");
Addition add = new Addition();
Subtraktion subtract = new Subtraktion();
Multiplikation multiply = new Multiplikation();
Division divide = new Division();
int int_a = 4;
int int_b = 8;
double double_a = 3.5;
double double_b = 10.5;

int result1 = add.add(int_a, int_b);
double result2 = add.add(int_a, double_b);
double result3 = add.add(double_a, int_b);
double result4 = add.add(double_a, double_b);

int result5 = subtract.subtract(int_a, int_b);
double result6 = subtract.subtract(int_a, double_b);
double result7 = subtract.subtract(double_a, int_b);
double result8 = subtract.subtract(double_a, double_b);

int result9 = multiply.multiply(int_a, int_b);
double result10 = multiply.multiply(int_a, double_b);
double result11 = multiply.multiply(double_a, int_b);
double result12 = multiply.multiply(double_a, double_b);

int result13 = divide.divide(int_a, int_b);
double result14 = divide.divide(int_a, double_b);
double result15 = divide.divide(double_a, int_b);
double result16 = divide.divide(double_a, double_b);

try {
System.out.println("Ergebnisse der Addition");
System.out.println(int_a + " + " + int_b + " = " + result1);
System.out.println(int_a + " + " + double_b + " = " + result2);
System.out.println(double_a + " + " + int_b + " = " + result3);
System.out.println(double_a + " + " + double_b + " = " + result4);
} catch (Exception e) {
System.out.println("Fehler bei der Addition");
System.out.println(e.getMessage());
}

try {
System.out.println("Ergebnisse der Subtrahierung");
System.out.println(int_a + " - " + int_b + " = " + result5);
System.out.println(int_a + " - " + double_b + " = " + result6);
System.out.println(double_a + " - " + int_b + " = " + result7);
System.out.println(double_a + " - " + double_b + " = " + result8);
} catch (Exception e) {
System.out.println("Fehler bei der Subtrahierung");
System.out.println(e.getMessage());
}

try {
System.out.println("Ergebnisse der Multiplikation");
System.out.println(int_a + " * " + int_b + " = " + result9);
System.out.println(int_a + " * " + double_b + " = " + result10);
System.out.println(double_a + " * " + int_b + " = " + result11);
System.out.println(double_a + " * " + double_b + " = " + result12);
} catch (Exception e) {
System.out.println("Fehler bei der Multiplikation");
System.out.println(e.getMessage());
}

public static void main(String[] args) {
System.out.println(new App().getGreeting());
try {
System.out.println("Ergebnisse der Division");
System.out.println(int_a + " / " + int_b + " = " + result13);
System.out.println(int_a + " / " + double_b + " = " + result14);
System.out.println(double_a + " / " + int_b + " = " + result15);
System.out.println(double_a + " / " + double_b + " = " + result16);
} catch (Exception e) {
System.out.println("Fehler bei der Division");
System.out.println(e.getMessage());
}
}
}
32 changes: 32 additions & 0 deletions app/src/main/java/hsw/gradle/template/Division.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package hsw.gradle.template;

public class Division{
public int divide(int a, int b) throws Exception {
if (b != 0) {
return a / b;
} else {
throw new Exception();
}
}
public double divide(int a, double b) throws Exception {
if (b != 0) {
return a / b;
} else {
throw new Exception();
}
}
public double divide(double a, int b) throws Exception {
if (b != 0) {
return a / b;
} else {
throw new Exception();
}
}
public double divide(double a, double b) throws Exception {
if (b != 0) {
return a / b;
} else {
throw new Exception();
}
}
}
16 changes: 16 additions & 0 deletions app/src/main/java/hsw/gradle/template/Multiplikation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package hsw.gradle.template;

public class Multiplikation {
public int multiply(int a, int b) {
return a * b;
}
public double multiply(int a, double b) {
return a * b;
}
public double multiply(double a, int b) {
return a * b;
}
public double multiply(double a, double b) {
return a * b;
}
}
16 changes: 16 additions & 0 deletions app/src/main/java/hsw/gradle/template/Subtraktion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package hsw.gradle.template;

public class Subtraktion {
public int subtract(int a, int b) {
return a - b;
}
public double subtract(int a, double b) {
return a - b;
}
public double subtract(double a, int b) {
return a - b;
}
public double subtract(double a, double b) {
return a - b;
}
}
14 changes: 0 additions & 14 deletions app/src/test/java/hsw/gradle/template/AppTest.java

This file was deleted.

38 changes: 38 additions & 0 deletions app/src/test/java/hsw/gradle/template/DivisionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package hsw.gradle.template;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

class DivisonTest {
@Test void divisionIntInt() throws Exception {
Division div = new Division();
int a = 15;
int b = 3;
int c = 5;
assertEquals(div.divide(a,b),c);
}

@Test void divisionIntDouble() throws Exception {
Division div = new Division();
int a = 14;
double b = 3.5;
double c = 4;
assertEquals(div.divide(a,b),c);
}

@Test void divisionDoubleInt() throws Exception {
Division div = new Division();
double a = 7.5;
int b = 3;
double c = 2.5;
assertEquals(div.divide(a,b),c);
}

@Test void divisionDoubleDouble() throws Exception {
Division div = new Division();
double a = 10.5;
double b = 3.5;
double c = 3;
assertEquals(div.divide(a,b),c);
}
}