compile and run

This commit is contained in:
Sebastian Brosch 2024-05-02 16:42:56 +02:00
parent 7f8b2953fb
commit 7dc5441c89

37
run.ps1 Normal file
View File

@ -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', '')
}