From 7dc5441c89e1e3b6ff2c7c8844675fd201d64be4 Mon Sep 17 00:00:00 2001 From: Sebastian Brosch Date: Thu, 2 May 2024 16:42:56 +0200 Subject: [PATCH] compile and run --- run.ps1 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 run.ps1 diff --git a/run.ps1 b/run.ps1 new file mode 100644 index 0000000..e723171 --- /dev/null +++ b/run.ps1 @@ -0,0 +1,37 @@ +<# +.SYNOPSIS + Runs the solution of a specific exercise. +.DESCRIPTION + This script runs the solution of a specific exercise. +.PARAMETER Vorlesung + The number of the lecture to run the solution. +.PARAMETER Aufgabe + The number of the exercise to run the solution. +.EXAMPLE + Run the solution of exercise 1 of lecture 12. + .\Run -Vorlesung 12 -Aufgabe 1 +#> +param( + [UInt16]$Vorlesung, + [Uint16]$Aufgabe +) + +if ((-not (Get-Command java -ErrorAction SilentlyContinue)) -or (-not (Get-Command javac -ErrorAction SilentlyContinue))) { + throw "Java is not installed. Please install Java." +} + +$formatVorlesung = '{0:d2}' -f $Vorlesung +$formatAufgabe = '{0:d2}' -f $Aufgabe + +Write-Host "Vorlesung $formatVorlesung / Aufgabe $formatAufgabe" + +$folderPathAufgabe = "VL$formatVorlesung/Aufgabe$formatAufgabe" +$filePathAufgabe = "$folderPathAufgabe/Aufgabe$formatAufgabe.java" + +if (Test-Path $folderPathAufgabe -PathType Container) { + Get-ChildItem -path $folderPathAufgabe -Filter *.java -File | ForEach-Object { &"javac" $_.FullName} +} + +if (Test-Path $filePathAufgabe -PathType Leaf) { + java $filePathAufgabe.Replace('/', '.').Replace('.java', '') +} \ No newline at end of file