unit test & packages

This commit is contained in:
Sage The DM 2025-01-22 15:40:12 +01:00
parent 3e595922e6
commit abe38e8416
14 changed files with 70 additions and 1 deletions

Binary file not shown.

View file

@ -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));
}
}

View file

@ -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;
}
}
}

View file

@ -0,0 +1,7 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}

View file

@ -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).

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -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;
}
}

View file

@ -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);
}
}