diff --git a/Code/Steiner/packagesStuff/bin/App.class b/Code/Steiner/packagesStuff/bin/App.class index baa6c67..dffc894 100644 Binary files a/Code/Steiner/packagesStuff/bin/App.class and b/Code/Steiner/packagesStuff/bin/App.class differ diff --git a/Code/Steiner/packagesStuff/bin/tech/photofuel/util/Txt.class b/Code/Steiner/packagesStuff/bin/tech/photofuel/util/Txt.class new file mode 100644 index 0000000..4119665 Binary files /dev/null and b/Code/Steiner/packagesStuff/bin/tech/photofuel/util/Txt.class differ diff --git a/Code/Steiner/packagesStuff/src/App.class b/Code/Steiner/packagesStuff/src/App.class new file mode 100644 index 0000000..49714e8 Binary files /dev/null and b/Code/Steiner/packagesStuff/src/App.class differ diff --git a/Code/Steiner/packagesStuff/src/App.java b/Code/Steiner/packagesStuff/src/App.java index 0a839f9..47a3187 100644 --- a/Code/Steiner/packagesStuff/src/App.java +++ b/Code/Steiner/packagesStuff/src/App.java @@ -1,5 +1,8 @@ public class App { public static void main(String[] args) throws Exception { - System.out.println("Hello, World!"); + // System.out.println(Txt.Left("Hello World", 5)); + // System.out.println(Txt.Left("Hello World", -2)); + // System.out.println(Txt.Left("Hello World", 122)); + // System.out.println(Txt.Left("Hello World", 0)); } } diff --git a/Code/Steiner/packagesStuff/src/tech/photofuel/util/Txt.class b/Code/Steiner/packagesStuff/src/tech/photofuel/util/Txt.class new file mode 100644 index 0000000..9153c5d Binary files /dev/null and b/Code/Steiner/packagesStuff/src/tech/photofuel/util/Txt.class differ diff --git a/Code/Steiner/packagesStuff/src/tech/photofuel/util/Txt.java b/Code/Steiner/packagesStuff/src/tech/photofuel/util/Txt.java new file mode 100644 index 0000000..c3e5802 --- /dev/null +++ b/Code/Steiner/packagesStuff/src/tech/photofuel/util/Txt.java @@ -0,0 +1,16 @@ +package tech.photofuel.util; + +public class Txt { + public static String Left(String text, int anzahlZeichen) { + try { + if (text.length() < anzahlZeichen) { + return text; + } else { + return text.substring(0, anzahlZeichen); + } + } catch (Exception e) { + System.out.println("Invalid input error: " + e); + return null; + } + } +} diff --git a/Code/Steiner/unitTest/.vscode/settings.json b/Code/Steiner/unitTest/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/unitTest/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/Steiner/unitTest/README.md b/Code/Steiner/unitTest/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/unitTest/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/Code/Steiner/unitTest/bin/App.class b/Code/Steiner/unitTest/bin/App.class new file mode 100644 index 0000000..5affc4f Binary files /dev/null and b/Code/Steiner/unitTest/bin/App.class differ diff --git a/Code/Steiner/unitTest/bin/AppTest.class b/Code/Steiner/unitTest/bin/AppTest.class new file mode 100644 index 0000000..c7a094a Binary files /dev/null and b/Code/Steiner/unitTest/bin/AppTest.class differ diff --git a/Code/Steiner/unitTest/lib/hamcrest-core-1.3.jar b/Code/Steiner/unitTest/lib/hamcrest-core-1.3.jar new file mode 100644 index 0000000..9d5fe16 Binary files /dev/null and b/Code/Steiner/unitTest/lib/hamcrest-core-1.3.jar differ diff --git a/Code/Steiner/unitTest/lib/junit-4.13.2.jar b/Code/Steiner/unitTest/lib/junit-4.13.2.jar new file mode 100644 index 0000000..6da55d8 Binary files /dev/null and b/Code/Steiner/unitTest/lib/junit-4.13.2.jar differ diff --git a/Code/Steiner/unitTest/src/App.java b/Code/Steiner/unitTest/src/App.java new file mode 100644 index 0000000..1b4837a --- /dev/null +++ b/Code/Steiner/unitTest/src/App.java @@ -0,0 +1,10 @@ +public class App { + public static void main(String[] args) { + App rechteckRechner = new App(); + System.out.println(rechteckRechner.calcUmfang(4.3, 5.7)); + } + + public double calcUmfang(double seiteA, double seiteB) { + return 2 * seiteA + 2 * seiteB; + } +} \ No newline at end of file diff --git a/Code/Steiner/unitTest/src/AppTest.java b/Code/Steiner/unitTest/src/AppTest.java new file mode 100644 index 0000000..12f7b15 --- /dev/null +++ b/Code/Steiner/unitTest/src/AppTest.java @@ -0,0 +1,15 @@ +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class AppTest { + @Test + public void testCalcUmfang() { + App calculation = new App(); + + assertEquals(-21, calculation.calcUmfang(-5, -5), 0.1); + assertEquals("0", calculation.calcUmfang(0, 0), 0.1); + assertEquals(2001000, calculation.calcUmfang(100000, 0), 0.1); + assertEquals(10, calculation.calcUmfang(-2, 7), 0.1); + } +}