diff --git a/Code/Steiner/Wrapper-theorie/.vscode/settings.json b/Code/Steiner/Wrapper-theorie/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/Wrapper-theorie/.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/Wrapper-theorie/README.md b/Code/Steiner/Wrapper-theorie/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/Wrapper-theorie/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/Wrapper-theorie/bin/NumberConverter.class b/Code/Steiner/Wrapper-theorie/bin/NumberConverter.class new file mode 100644 index 0000000..c89fa6d Binary files /dev/null and b/Code/Steiner/Wrapper-theorie/bin/NumberConverter.class differ diff --git a/Code/Steiner/Wrapper-theorie/src/NumberConverter.class b/Code/Steiner/Wrapper-theorie/src/NumberConverter.class new file mode 100644 index 0000000..dda8b37 Binary files /dev/null and b/Code/Steiner/Wrapper-theorie/src/NumberConverter.class differ diff --git a/Code/Steiner/Wrapper-theorie/src/NumberConverter.java b/Code/Steiner/Wrapper-theorie/src/NumberConverter.java new file mode 100644 index 0000000..10b797b --- /dev/null +++ b/Code/Steiner/Wrapper-theorie/src/NumberConverter.java @@ -0,0 +1,41 @@ +import java.util.Scanner; + +public class NumberConverter { + public static void main(String[] args) { + // User input + Scanner scanner = new Scanner(System.in); + System.out.print("Please enter an integer: "); + String input = scanner.nextLine(); + + // Convert input to an Integer object + Integer number = Integer.valueOf(input); + + // A1) Display the entered number + System.out.println("A1) Entered number: " + number.toString()); + + // A2) Convert to binary and display + String binaryString = Integer.toBinaryString(number); + System.out.println("A2) Number in binary: " + binaryString); + + // A3) Convert to hexadecimal and display + String hexString = Integer.toHexString(number); + System.out.println("A3) Number in hexadecimal: " + hexString); + + // A4) Display the maximum value for Integer + System.out.println("A4) Maximum value of Integer: " + Integer.MAX_VALUE); + + // A5) Display the minimum value for Integer + System.out.println("A5) Minimum value of Integer: " + Integer.MIN_VALUE); + + // B1) Convert the binary string back to decimal and display + Integer fromBinary = Integer.valueOf(binaryString, 2); + System.out.println("B1) Converted back from binary: " + fromBinary.toString()); + + // B2) Convert the hexadecimal string back to decimal and display + Integer fromHex = Integer.valueOf(hexString, 16); + System.out.println("B2) Converted back from hexadecimal: " + fromHex.toString()); + + // Close the scanner + scanner.close(); + } +} diff --git a/Code/ost/_05_layouts/src/main/java/com/example/App.java b/Code/ost/_05_layouts/src/main/java/com/example/App.java index b9dbc2d..1248f16 100644 --- a/Code/ost/_05_layouts/src/main/java/com/example/App.java +++ b/Code/ost/_05_layouts/src/main/java/com/example/App.java @@ -1,23 +1,64 @@ +//#region imports package com.example; import javafx.application.Application; +import javafx.geometry.Insets; +import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.scene.shape.Circle; +import javafx.scene.shape.Rectangle; +import javafx.scene.text.Text; import javafx.stage.Stage; -/** - * JavaFX App with AnchorPane layout - */ +//#region launcher public class App extends Application { + private Stage primaryStage; + + public static void main(String[] args) { + launch(args); + } + @Override public void start(Stage stage) { - // Create AnchorPane + this.primaryStage = stage; + showStackPane(); // Change this line to launch a different scene + } + + // #region HBox Scene + private void showHBoxScene() { + HBox hbox = new HBox(); + hbox.setPadding(new Insets(10, 20, 20, 20)); + hbox.setSpacing(15); + + // Create two buttons + Button leftButton = new Button("Left"); + Button rightButton = new Button("Right"); + + // Add buttons to the HBox + hbox.getChildren().addAll(leftButton, rightButton); + hbox.setAlignment(Pos.CENTER); + + Scene scene = new Scene(hbox, 250, 150); + primaryStage.setTitle("Hauptfenster - HBox Scene"); + primaryStage.setScene(scene); + primaryStage.show(); + } + // #endregion + + // #region AnchorPane Scene + private void showAnchorPaneScene() { AnchorPane anchorPane = new AnchorPane(); - // Create Controll button - Button mainButton = new Button("Button"); + // Create Control button + Button mainButton = new Button("Main Button"); AnchorPane.setTopAnchor(mainButton, 50.0); AnchorPane.setLeftAnchor(mainButton, 50.0); AnchorPane.setRightAnchor(mainButton, 10.0); @@ -31,14 +72,59 @@ public class App extends Application { // Add buttons to the pane anchorPane.getChildren().addAll(mainButton, button1); - // Set up the Scene with AnchorPane Scene scene = new Scene(anchorPane, 640, 480); - stage.setTitle("Hauptfenster with AnchorPane"); - stage.setScene(scene); - stage.show(); + primaryStage.setTitle("Hauptfenster - AnchorPane Scene"); + primaryStage.setScene(scene); + primaryStage.show(); } + // #endregion - public static void main(String[] args) { - launch(); + // #region VBox Scene + private void showVBoxScene() { + VBox vbox = new VBox(); + vbox.setSpacing(8); + + // Create the buttons + Button growButton = new Button("Lass mich wachsen!"); + Button relaxButton = new Button("Lass mich in ruhe!"); + + // Set grow priority for the growButton + VBox.setVgrow(growButton, Priority.ALWAYS); + growButton.setMaxHeight(500); + + // Add buttons to the VBox + vbox.getChildren().addAll(growButton, relaxButton); + + Scene scene = new Scene(vbox, 200, 400); + primaryStage.setTitle("VBox Scene"); + primaryStage.setScene(scene); + primaryStage.show(); } + // #endregion + + // #region StackPane Scene + private void showStackPane() { + StackPane stackPane = new StackPane(); + + // Create a circle + Circle circle = new Circle(100); + circle.setFill(Color.DARKSLATEBLUE); + circle.setStroke(Color.BLACK); + + // Create a rectangle + Rectangle rectangle = new Rectangle(50, 50); + + // Create a text + Text text = new Text("Hello World"); + text.setFill(Color.CRIMSON); + + // Add the shapes and text to the StackPane + stackPane.getChildren().addAll(circle, rectangle, text); + + Scene scene = new Scene(stackPane, 300, 300); + primaryStage.setTitle("StackPane Scene"); + primaryStage.setScene(scene); + primaryStage.show(); + } + // #endregion } diff --git a/Code/ost/_05_layouts/src/main/java/com/example/SystemInfo.java b/Code/ost/_05_layouts/src/main/java/com/example/SystemInfo.java deleted file mode 100644 index b566a3e..0000000 --- a/Code/ost/_05_layouts/src/main/java/com/example/SystemInfo.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example; - -public class SystemInfo { - - public static String javaVersion() { - return System.getProperty("java.version"); - } - - public static String javafxVersion() { - return System.getProperty("javafx.version"); - } - -} \ No newline at end of file diff --git a/Code/ost/_05_layouts/target/classes/com/example/App.class b/Code/ost/_05_layouts/target/classes/com/example/App.class index 440c998..873f5c2 100644 Binary files a/Code/ost/_05_layouts/target/classes/com/example/App.class and b/Code/ost/_05_layouts/target/classes/com/example/App.class differ