From 0079221776106e3ca91076938e80d37e38eacc29 Mon Sep 17 00:00:00 2001
From: Hong-Phuc Bui <hong-phuc.bui@htwsaar.de>
Date: Fri, 17 Oct 2025 07:01:14 +0200
Subject: [PATCH] 1. Vorlesung
---
textbased-programms/gravitation.js | 12 +-
.gitignore | 8 +
textbased-programms/flipping-a-coin.js | 2
textbased-programms/prime-bigint.html | 6
textbased-programms/taylor-serie-exp.js | 10 +-
textbased-programms/luhn.js | 8
textbased-programms/quadratic-equation.js | 16 +-
textbased-programms/virus-expand.html | 7 +
textbased-programms/power-of-2.js | 4
textbased-programms/monitor.js | 2
textbased-programms/linked-list.html | 6
textbased-programms/point-to-text.js | 2
textbased-programms/echo.js | 2
textbased-programms/quadratic-equation.html | 2
textbased-programms/power-of-2-multi.js | 4
textbased-programms/cys-a3.js | 2
textbased-programms/helloworld-html.js | 2
textbased-programms/dice-simulation.js | 2
textbased-programms/virus-expand.js | 6
textbased-programms/newton-method-sqrt.html | 7
textbased-programms/prime-bigint-function.js | 8
textbased-programms/point-to-text.html | 5
textbased-programms/euclidean-algorithm.js | 2
textbased-programms/harmonic.js | 2
textbased-programms/helloworld-terminal.js | 2
textbased-programms/power-of-2.html | 4
textbased-programms/newton-method-sqrt.js | 4
textbased-programms/prime-bigint-function.html | 7
textbased-programms/arithmetic-op.js | 10 +-
textbased-programms/chess.js | 5
textbased-programms/new-program.py | 2
textbased-programms/power-of-2-multi.html | 5
README.md | 5 +
textbased-programms/triangle-star.js | 2
textbased-programms/hello-name.js | 2
/dev/null | 10 --
textbased-programms/taylor-serie-trigonometry.js | 10 +-
textbased-programms/triangle-star.html | 6
textbased-programms/hash-and-star.js | 2
textbased-programms/prime-bigint.js | 7
textbased-programms/linked-list.js | 32 +++---
textbased-programms/literal-object.js | 5
textbased-programms/binary.js | 2
textbased-programms/drawing-hands.js | 6
textbased-programms/literal-object.html | 11 +
45 files changed, 144 insertions(+), 122 deletions(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..dbff60e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+*/.idea/*
+.idea/*
+.idea
+helloworld-terminal/dfhi-dom.js
+*/data.csv
+**/img/permutation.*
+*/.parcel-cache
+node_modules
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..52d3851
--- /dev/null
+++ b/README.md
@@ -0,0 +1,5 @@
+Beispiel-Projekten im Jahrgang 2024/2025
+
+
+
+
diff --git a/textbased-programms/arithmetic-op.js b/textbased-programms/arithmetic-op.js
index 9c366e8..0078520 100644
--- a/textbased-programms/arithmetic-op.js
+++ b/textbased-programms/arithmetic-op.js
@@ -6,10 +6,10 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
- let a = 12;
- let b = 5;
- let c = Math.floor(12/5); // 2
- let d = (12/5) | 0;
+window.main = (...argv)=> {
+ const a = 12;
+ const b = 5;
+ const c = Math.floor(a/b); // 2
+ const d = (a/b) | 0;
terminal.print(c);
};
\ No newline at end of file
diff --git a/textbased-programms/binary.js b/textbased-programms/binary.js
index 5694560..5feffc2 100644
--- a/textbased-programms/binary.js
+++ b/textbased-programms/binary.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
let n = BigInt(argv[0]);
let power = 1n;
const LIMIT = n / 2n;
diff --git a/textbased-programms/chess.js b/textbased-programms/chess.js
index c23e683..6a107d0 100644
--- a/textbased-programms/chess.js
+++ b/textbased-programms/chess.js
@@ -11,7 +11,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
let n = Number.parseInt(argv[0]);
terminal.clear();
printTopBottomLine(n);
@@ -33,8 +33,7 @@
};
-function printTopBottomLine(n, symbol='_')
-{
+const printTopBottomLine = (n, symbol='_') => {
terminal.print('.');
for(let i = 0; i < n; ++i) {
terminal.print(symbol);
diff --git a/textbased-programms/cys-a3.js b/textbased-programms/cys-a3.js
index afe1448..db1c1f0 100644
--- a/textbased-programms/cys-a3.js
+++ b/textbased-programms/cys-a3.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
let a = 0,
b = 1;
for(let i = 0; i < 15; ++i) {
diff --git a/textbased-programms/dice-simulation.js b/textbased-programms/dice-simulation.js
index c80e298..e8e512c 100644
--- a/textbased-programms/dice-simulation.js
+++ b/textbased-programms/dice-simulation.js
@@ -8,7 +8,7 @@
/**
* Simulation eines Würfel
* */
-window.main = function(...argv) {
+window.main = (...argv) => {
const IMG_DIR = "./dice-simulation/assert";
let min = 1;
diff --git a/textbased-programms/drawing-hands.js b/textbased-programms/drawing-hands.js
index b813e55..94d68a2 100644
--- a/textbased-programms/drawing-hands.js
+++ b/textbased-programms/drawing-hands.js
@@ -5,15 +5,15 @@
import {terminal} from "./dfhi.js";
-function leftHand() {
+const leftHand = () => {
return rightHand();
}
-function rightHand() {
+const rightHand = () => {
return leftHand();
}
-window.main = function(...argv) {
+window.main = (...argv) => {
terminal.printl(leftHand() + " draws first!");
};
diff --git a/textbased-programms/echo.js b/textbased-programms/echo.js
index 522a3c5..8585468 100644
--- a/textbased-programms/echo.js
+++ b/textbased-programms/echo.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
terminal.clear();
for(let arg of argv) {
terminal.printl(arg);
diff --git a/textbased-programms/euclidean-algorithm.js b/textbased-programms/euclidean-algorithm.js
index 32a4579..d7fcc06 100644
--- a/textbased-programms/euclidean-algorithm.js
+++ b/textbased-programms/euclidean-algorithm.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
let a = Number.parseInt(argv[0], 10);
let b = Number.parseInt(argv[1], 10);
let t = b;
diff --git a/textbased-programms/flipping-a-coin.js b/textbased-programms/flipping-a-coin.js
index 87cd674..3473fbd 100644
--- a/textbased-programms/flipping-a-coin.js
+++ b/textbased-programms/flipping-a-coin.js
@@ -1,6 +1,6 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
if( Math.random() < 0.5) {
terminal.printl("Kopf");
} else {
diff --git a/textbased-programms/gravitation.js b/textbased-programms/gravitation.js
index 2df66a6..528efbc 100644
--- a/textbased-programms/gravitation.js
+++ b/textbased-programms/gravitation.js
@@ -12,12 +12,10 @@
const G = 6.67430;
-window.main = function(...argv) {
- /*const mass1 = parseFloat(argv[0]);
- const mass2 = parseFloat(argv[1]);
- const r = parseFloat(argv[2]);
- let force = G * mass1 * mass2 / (r*r);
- */
- //(a < b+ c) && (b < a + c) && (c < b + a);
+window.main = (...argv) => {
+ const mass1 = Number(argv[0]);
+ const mass2 = Number(argv[1]);
+ const r = Number(argv[2]);
+ const force = G * mass1 * mass2 / (r*r);
terminal.printh(force);
};
diff --git a/textbased-programms/harmonic.js b/textbased-programms/harmonic.js
index cb30696..8a0d23e 100644
--- a/textbased-programms/harmonic.js
+++ b/textbased-programms/harmonic.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
const n = Number.parseInt(argv[0]);
let h = 0;
for(let i = 1; i <=n; ++i) {
diff --git a/textbased-programms/hash-and-star.js b/textbased-programms/hash-and-star.js
index 35676cc..4e6b410 100644
--- a/textbased-programms/hash-and-star.js
+++ b/textbased-programms/hash-and-star.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
let n = Number.parseInt(argv[0]);
let stars = '<table>';
// Code to create table (with tr and td....
diff --git a/textbased-programms/hello-name.js b/textbased-programms/hello-name.js
index 72f3384..fd08c53 100644
--- a/textbased-programms/hello-name.js
+++ b/textbased-programms/hello-name.js
@@ -6,7 +6,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
let name = argv[0];
terminal.print(`Hallo, ${name}!`)
};
\ No newline at end of file
diff --git a/textbased-programms/helloworld-html.js b/textbased-programms/helloworld-html.js
index 3e54cc0..e49a345 100644
--- a/textbased-programms/helloworld-html.js
+++ b/textbased-programms/helloworld-html.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
let name = argv[0];
let color = 'blue';
let greeting = `<span style='color:${color}'>
diff --git a/textbased-programms/helloworld-terminal.js b/textbased-programms/helloworld-terminal.js
index c52ad7d..d167f08 100644
--- a/textbased-programms/helloworld-terminal.js
+++ b/textbased-programms/helloworld-terminal.js
@@ -7,6 +7,6 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
terminal.printl("Hello world");
};
diff --git a/textbased-programms/linked-list.html b/textbased-programms/linked-list.html
index 7013546..5c73726 100644
--- a/textbased-programms/linked-list.html
+++ b/textbased-programms/linked-list.html
@@ -7,9 +7,9 @@
<link rel="stylesheet" href="dfhi.css" />
</head>
<body>
-<p class="description">(Passen Sie die Beschreibung des Programs hier an.)</p>
-<label for="argv"><code>main</code>'s arguments:</label> <input type="text" id="argv" name="argv" />
-<button name="run" id="run" >Rerun</button>
+<p class="description">Demo Linked List. </p>
+<p>To start program click run</p>
+<button name="run" id="run" >Run</button>
<pre id="text-output"></pre>
diff --git a/textbased-programms/linked-list.js b/textbased-programms/linked-list.js
index 974f2b9..230a176 100644
--- a/textbased-programms/linked-list.js
+++ b/textbased-programms/linked-list.js
@@ -5,7 +5,20 @@
import {terminal} from "./dfhi.js";
-function insert(list, value) {
+window.main = () => {
+ let list = {
+ head: {
+ value: "b",
+ next: null
+ }
+ };
+ append(list, "c");
+ terminal.printl(toString(list)); // → (head) -> b -> c -> (null)
+ insert(list, "a");
+ terminal.printl(toString(list)); // → (head) -> a -> b -> c -> (null)
+};
+
+const insert = (list, value) => {
try{
let head = {
value: value,
@@ -19,7 +32,7 @@
}
}
-function append(list, value) {
+const append = (list, value) => {
try{
let nextElement = list.head;
while(nextElement.next != null) {
@@ -36,7 +49,7 @@
}
}
-function toString(list) {
+const toString = (list) => {
try{
let nextElement = list.head;
let representation = `(head) -> ${nextElement.value}`;
@@ -52,16 +65,5 @@
}
}
-window.main = function(...argv) {
- let list = {
- head: {
- value: "b",
- next: null
- }
- };
- append(list, "c");
- terminal.printl(toString(list)); // → (head) -> b -> c -> (null)
- insert(list, "a");
- terminal.printl(toString(list)); // → (head) -> a -> b -> c -> (null)
-};
+
diff --git a/textbased-programms/literal-object.html b/textbased-programms/literal-object.html
index 6d58637..0cd4d91 100644
--- a/textbased-programms/literal-object.html
+++ b/textbased-programms/literal-object.html
@@ -7,13 +7,16 @@
<link rel="stylesheet" href="dfhi.css" />
</head>
<body>
-<p class="description">(Passen Sie die Beschreibung des Programs hier an.)</p>
-<label for="argv"><code>main</code>'s arguments:</label> <input type="text" id="argv" name="argv" />
-<button name="run" id="run" >Rerun</button>
-
+<p class="description">Demo literal object</p>
+<button name="run" id="run" >(Re)run</button>
<pre id="text-output"></pre>
<script type="module" src="literal-object.js"></script>
+<p>
+ Was passiert mit dem Objekt <code>v2</code> bzw. <code>v3</code>
+ wenn Sie <code>v1.key1 = 13</code> nach der Schleife schreiben?
+ (S. Sourcecode)
+</p>
</body>
</html>
diff --git a/textbased-programms/literal-object.js b/textbased-programms/literal-object.js
index 3f813dd..1a28359 100644
--- a/textbased-programms/literal-object.js
+++ b/textbased-programms/literal-object.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
let v1 = undefined,
v2 = undefined,
v3 = undefined;
@@ -20,4 +20,7 @@
case 2:{v3 = obj; break;}
}
}
+ terminal.print(v1);
+ terminal.print(v2);
+ terminal.print(v3);
};
diff --git a/textbased-programms/loop-test.html b/textbased-programms/loop-test.html
deleted file mode 100644
index c57eef1..0000000
--- a/textbased-programms/loop-test.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <title>loop-test</title>
- <link rel="stylesheet" href="dom-output.css" />
- <link rel="stylesheet" href="dfhi.css" />
-</head>
-<body>
-<p class="description">(Passen Sie die Beschreibung des Programs hier an.)</p>
-<label for="argv"><code>main</code>'s arguments:</label> <input type="text" id="argv" name="argv" />
-<button name="run" id="run" >Rerun</button>
-
-
-<pre id="text-output"></pre>
-<script type="module" src="loop-test.js"></script>
-
-</body>
-</html>
diff --git a/textbased-programms/loop-test.js b/textbased-programms/loop-test.js
deleted file mode 100644
index 6122652..0000000
--- a/textbased-programms/loop-test.js
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * loop-test.js
- *
- */
-
-import {terminal} from "./dfhi.js";
-
-window.main = function(...argv) {
- terminal.print("loop-test");
-};
diff --git a/textbased-programms/luhn.js b/textbased-programms/luhn.js
index cd2e319..0e5fa80 100644
--- a/textbased-programms/luhn.js
+++ b/textbased-programms/luhn.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
let sumEvent = 0n;
let sumOdd = 0n;
let credit = argv[0];
@@ -20,10 +20,10 @@
n = n/10n;
}
console.log({sumOdd, sumEvent});
- let sum =(sumEvent + sumOdd) % 10n;
+ const sum =(sumEvent + sumOdd) % 10n;
if (sum === 0n) {
- terminal.printl(`${credit} maybe OK`);
+ terminal.printl(`${credit} may be a valid credit number`);
} else {
- terminal.printl(`${credit} definitiv Wrong`);
+ terminal.printl(`${credit} is not a valid credit number`);
}
};
diff --git a/textbased-programms/monitor.js b/textbased-programms/monitor.js
index cc60cc0..aedeaff 100644
--- a/textbased-programms/monitor.js
+++ b/textbased-programms/monitor.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
// b:h als ratio, Bruch (numerator/denominator)
const numerator = Number.parseFloat(argv[0]);
const denominator = Number.parseFloat(argv[1]);
diff --git a/textbased-programms/new-program.py b/textbased-programms/new-program.py
index 85b0cb7..2b69c72 100644
--- a/textbased-programms/new-program.py
+++ b/textbased-programms/new-program.py
@@ -45,7 +45,7 @@
import {{terminal}} from "./dfhi.js";
-window.main = function(...argv) {{
+window.main = (...argv) => {{
terminal.print("{program}");
}};
"""
diff --git a/textbased-programms/newton-method-sqrt.html b/textbased-programms/newton-method-sqrt.html
index a197f08..67947aa 100644
--- a/textbased-programms/newton-method-sqrt.html
+++ b/textbased-programms/newton-method-sqrt.html
@@ -8,9 +8,10 @@
</head>
<body>
-<p class="description">Programm zum Testen der Implementierung von Newton-Verfahen. Klicken Sie auf dem „Ok“ Button um das Erebnis anzeigen zu lassen.
-Das Programm akzeptiert keine Eingabe.</p>
-<!--code>main</code>'s arguments: <input disabled="disabled" type="text" id="argv" name="argv" /-->
+<p class="description">Programm zum Testen der Implementierung von Newton-Verfahren.
+ Klicken Sie auf dem „Ok“ Button um das Erebnis anzeigen zu lassen.
+ Das Programm akzeptiert keine Eingabe.
+</p>
<button name="run" id="run" >Ok</button>
diff --git a/textbased-programms/newton-method-sqrt.js b/textbased-programms/newton-method-sqrt.js
index e9c8eaf..da7d931 100644
--- a/textbased-programms/newton-method-sqrt.js
+++ b/textbased-programms/newton-method-sqrt.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
const testData = [0, 1.25, 3.758, 4.229, 6.735, 123456.789, (1<<30) + 1];
for(const c of testData) {
const cquad = c*c;
@@ -15,7 +15,7 @@
}
};
-function sqrt(c) {
+const sqrt = (c) => {
const EPSILON = 1E-16;
let xn = c;
let q = c/xn; // auxiliary variable to avoid multiple division c/xn
diff --git a/textbased-programms/point-to-text.html b/textbased-programms/point-to-text.html
index 63c81d9..de48197 100644
--- a/textbased-programms/point-to-text.html
+++ b/textbased-programms/point-to-text.html
@@ -7,8 +7,9 @@
<link rel="stylesheet" href="dfhi.css" />
</head>
<body>
-
-<code>main</code>'s arguments: <input type="text" id="argv" name="argv" />
+<p class="description">Zuordnung Punkten zu Leistung</p>
+<label for="argv">Geben Sie die Punkte zwischen 0 und 100 ein!</label>
+<input type="text" id="argv" name="argv" />
<button name="run" id="run" >Rerun</button>
diff --git a/textbased-programms/point-to-text.js b/textbased-programms/point-to-text.js
index 21e3565..c19cf0d 100644
--- a/textbased-programms/point-to-text.js
+++ b/textbased-programms/point-to-text.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
let points = Number.parseFloat(argv[0]);
if (points < 0) {
terminal.printl("Kein gültiger Punkt");
diff --git a/textbased-programms/power-of-2-multi.html b/textbased-programms/power-of-2-multi.html
index 8fdb4aa..4728888 100644
--- a/textbased-programms/power-of-2-multi.html
+++ b/textbased-programms/power-of-2-multi.html
@@ -7,8 +7,9 @@
<link rel="stylesheet" href="dfhi.css" />
</head>
<body>
-
-<code>main</code>'s arguments: <input type="text" id="argv" name="argv" />
+<p class="description">Programm zum Berechnen 2^n</p>
+<label for="argv">Geben Sie die Zahl n ein!</label>
+<input type="text" id="argv" name="argv" />
<button name="run" id="run" >Rerun</button>
diff --git a/textbased-programms/power-of-2-multi.js b/textbased-programms/power-of-2-multi.js
index 114d21f..65fbc74 100644
--- a/textbased-programms/power-of-2-multi.js
+++ b/textbased-programms/power-of-2-multi.js
@@ -5,8 +5,8 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
- let n = Number.parseInt(argv[0], 10);
+window.main = (...argv) => {
+ const n = Number.parseInt(argv[0], 10);
let power = 1;
let i = 0;
while (i <= n) {
diff --git a/textbased-programms/power-of-2.html b/textbased-programms/power-of-2.html
index 3d504f7..eea86c6 100644
--- a/textbased-programms/power-of-2.html
+++ b/textbased-programms/power-of-2.html
@@ -8,7 +8,9 @@
</head>
<body>
-<code>main</code>'s arguments: <input type="text" id="argv" name="argv" />
+<p class="description">Programm zum Berechnen 2^n</p>
+<label for="argv">Geben Sie die Zahl n ein!</label>
+<input type="text" id="argv" name="argv" />
<button name="run" id="run" >Rerun</button>
diff --git a/textbased-programms/power-of-2.js b/textbased-programms/power-of-2.js
index fb262a5..0f99677 100644
--- a/textbased-programms/power-of-2.js
+++ b/textbased-programms/power-of-2.js
@@ -5,8 +5,8 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
- let n = Number.parseInt(argv[0], 10);
+window.main = (...argv) => {
+ const n = Number.parseInt(argv[0], 10);
let power = 1;
let i = -1;
while( ++i <= n) {
diff --git a/textbased-programms/prime-bigint-function.html b/textbased-programms/prime-bigint-function.html
index 73e1ebc..0b41630 100644
--- a/textbased-programms/prime-bigint-function.html
+++ b/textbased-programms/prime-bigint-function.html
@@ -7,9 +7,10 @@
<link rel="stylesheet" href="dfhi.css" />
</head>
<body>
-
-<code>main</code>'s arguments: <input type="text" id="argv" name="argv" />
-<button name="run" id="run" >Rerun</button>
+<p class="description">Primzahl test</p>
+<label for="argv">Geben Sie eine natürliche Zahl ein!</label>
+<input type="text" id="argv" name="argv" />
+<button name="run" id="run" >OK</button>
<pre id="text-output"></pre>
diff --git a/textbased-programms/prime-bigint-function.js b/textbased-programms/prime-bigint-function.js
index 5448cd2..5f42c55 100644
--- a/textbased-programms/prime-bigint-function.js
+++ b/textbased-programms/prime-bigint-function.js
@@ -8,9 +8,9 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
- let n = BigInt(argv[0]);
- let primeTest = isPrime(n);
+window.main = (...argv) => {
+ const n = BigInt(argv[0]);
+ const primeTest = isPrime(n);
if (primeTest) {
terminal.printl(`${n} ist eine Primzahl`);
} else {
@@ -18,7 +18,7 @@
}
};
-function isPrime(n) {
+const isPrime = (n) => {
let p = BigInt(n);
if (p < 2n) {
return false;
diff --git a/textbased-programms/prime-bigint.html b/textbased-programms/prime-bigint.html
index 5c59a22..aa6257e 100644
--- a/textbased-programms/prime-bigint.html
+++ b/textbased-programms/prime-bigint.html
@@ -8,8 +8,10 @@
</head>
<body>
-<code>Main Function</code>'s arguments: <input type="text" id="argv" name="argv" />
-<button name="run" id="run" >Rerun</button>
+<p class="description">Primzahl test</p>
+<label for="argv">Geben Sie eine natürliche Zahl ein!</label>
+<input type="text" id="argv" name="argv" />
+<button name="run" id="run" >OK</button>
<pre id="text-output"></pre>
diff --git a/textbased-programms/prime-bigint.js b/textbased-programms/prime-bigint.js
index 2d9ee1e..e3f0fbb 100644
--- a/textbased-programms/prime-bigint.js
+++ b/textbased-programms/prime-bigint.js
@@ -5,9 +5,10 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
- let n = BigInt(argv[0]);
- for (var factor = 2n; factor <= n/factor; ++factor) { // factor is used after the for-loop, therefore var
+window.main = (...argv) => {
+ const n = BigInt(argv[0]);
+ // factor is used after the for-loop, therefore var
+ for (var factor = 2n; factor <= n/factor; ++factor) {
if (n % factor === 0n) {
break;
}
diff --git a/textbased-programms/quadratic-equation.html b/textbased-programms/quadratic-equation.html
index f736859..a3f3e2a 100644
--- a/textbased-programms/quadratic-equation.html
+++ b/textbased-programms/quadratic-equation.html
@@ -8,7 +8,7 @@
<link rel="stylesheet" href="dfhi.css" />
</head>
<body>
-
+<p class="description">Programm zum Lösen einer quadratischen Gleichung</p>
<label for="argv">Geben Sie die Parameter a, b, c einer quadratischen Gleichung, getrennt von Leerzeichen ein!
Zum Beispiel <code>1 -3 2</code><br/>
</label>
diff --git a/textbased-programms/quadratic-equation.js b/textbased-programms/quadratic-equation.js
index cef0755..ecfe479 100644
--- a/textbased-programms/quadratic-equation.js
+++ b/textbased-programms/quadratic-equation.js
@@ -5,14 +5,14 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
- let a = Number(argv[0]),
- b = Number(argv[1]),
- c = Number(argv[2]);
- let delta = b*b - 4*a*c;
- let d = Math.sqrt(delta);
- let x1 = (-b + d) / (2*a),
- x2 = (-b - d) / (2*a);
+window.main = (...argv) => {
+ const a = Number(argv[0]),
+ b = Number(argv[1]),
+ c = Number(argv[2]);
+ const delta = b*b - 4*a*c;
+ const d = Math.sqrt(delta);
+ const x1 = (-b + d) / (2*a),
+ x2 = (-b - d) / (2*a);
terminal.printl(`Equation: ${a}x^2 + (${b})x + (${c})`);
terminal.printl(`first solution: ${x1}`);
diff --git a/textbased-programms/taylor-serie-exp.js b/textbased-programms/taylor-serie-exp.js
index e4f8930..cb33fab 100644
--- a/textbased-programms/taylor-serie-exp.js
+++ b/textbased-programms/taylor-serie-exp.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
const x = Number.parseFloat(argv[0]);
const variant1 = exp1(x);
const variant2 = exp2(x);
@@ -23,7 +23,7 @@
-function exp1(x) {
+const exp1 = (x) => {
let sum = 1.0;
const NUM_OF_TERM = 10;
//DEBUG: let expression = "1";
@@ -41,7 +41,7 @@
return sum;
}
-function exp2(x) {
+const exp2 = (x) => {
let sum = 1.0;
const NUM_OF_TERM = 1000;
for(let n = 1; n <= NUM_OF_TERM; ++n){
@@ -54,7 +54,7 @@
return sum;
}
-function exp3(x) {
+const exp3 = (x) => {
let sum = 0.0,
term = 1.0;
for(let n = 1; sum !== sum + term; ++n) {
@@ -67,7 +67,7 @@
return sum;
}
-function exp4(x) {
+const exp4 = (x) => {
let sum = 0.0,
term = 1.0;
for(let i = 1; sum !== sum+term; ++i) {
diff --git a/textbased-programms/taylor-serie-trigonometry.js b/textbased-programms/taylor-serie-trigonometry.js
index 43cd8ba..2073b67 100644
--- a/textbased-programms/taylor-serie-trigonometry.js
+++ b/textbased-programms/taylor-serie-trigonometry.js
@@ -5,8 +5,8 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
- //const x = Number.parseFloat(argv[0]);
+window.main = (...argv) => {
+ //const x = Number(argv[0]);
//const x_rad = x * Math.PI / 180;
const alpha = [0, 30, 45, 60, 90];
alpha.map(x => x*Math.PI/180).forEach( a => {
@@ -17,13 +17,13 @@
};
-function makeTest(testName, value, impl, ref) {
+const makeTest = (testName, value, impl, ref) => {
const result = impl(value);
const expected = ref(value);
terminal.print(`${testName} result: ${result} expected : ${expected}\n`);
}
-function sin(x) {
+const sin = (x) => {
let sum = x;
let term = -(x**3 / 6);
const xsqr = x*x;
@@ -36,7 +36,7 @@
return sum;
}
-function cos(x) {
+const cos = (x) => {
let sum = 1;
const xsqr = x*x;
let g = 2;
diff --git a/textbased-programms/triangle-star.html b/textbased-programms/triangle-star.html
index 4f3f499..23cb3d6 100644
--- a/textbased-programms/triangle-star.html
+++ b/textbased-programms/triangle-star.html
@@ -7,11 +7,13 @@
<link rel="stylesheet" href="dfhi.css" />
</head>
<body>
-
+<p class="description">Programm zum Ausgeben eines Dreiecks aus <code>*</code></p>
+<p class="description">
+ Geben Sie die Anzahl der Zeile ein (z.B. 6)!
+</p>
<code>main</code>'s arguments: <input type="text" id="argv" name="argv" />
<button name="run" id="run" >Rerun</button>
-
<pre id="text-output"></pre>
<script type="module" src="triangle-star.js"></script>
diff --git a/textbased-programms/triangle-star.js b/textbased-programms/triangle-star.js
index 1de6a3b..dc352af 100644
--- a/textbased-programms/triangle-star.js
+++ b/textbased-programms/triangle-star.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
+window.main = (...argv) => {
let n = Number.parseInt(argv[0], 10);
const character = "*",
separator = " ";
diff --git a/textbased-programms/virus-expand.html b/textbased-programms/virus-expand.html
index 8d95e0a..c8bf8d2 100644
--- a/textbased-programms/virus-expand.html
+++ b/textbased-programms/virus-expand.html
@@ -7,8 +7,11 @@
<link rel="stylesheet" href="dfhi.css" />
</head>
<body>
-<p class="description">(Passen Sie die Beschreibung des Programs hier an.)</p>
-<label for="argv"><code>main</code>'s arguments:</label> <input type="text" id="argv" name="argv" />
+<p class="description">
+ Geben Sie die Anzahl der infizierten Rechner und die Verbreitungsrate ein!
+</p>
+<label for="argv"><code>main</code>'s arguments:</label>
+<input type="text" id="argv" name="argv" />
<button name="run" id="run" >Rerun</button>
diff --git a/textbased-programms/virus-expand.js b/textbased-programms/virus-expand.js
index a7b588a..295b36a 100644
--- a/textbased-programms/virus-expand.js
+++ b/textbased-programms/virus-expand.js
@@ -5,9 +5,9 @@
import {terminal} from "./dfhi.js";
-window.main = function(...argv) {
- let n = Number.parseInt(argv[0], 10);
- let k = Number.parseFloat(argv[1]);
+window.main = (...argv) => {
+ const n = Number.parseInt(argv[0], 10);
+ const k = Number.parseFloat(argv[1]);
terminal.printl(`n = ${n}`);
terminal.printl(`k = ${k}`);
terminal.printl("Min Fälle");
--
Gitblit v1.10.0