From 85e9b6730a1c181d3c0d4a1a11ea3648dfac717c Mon Sep 17 00:00:00 2001
From: Hong-Phuc Bui <hong-phuc.bui@htwsaar.de>
Date: Fri, 17 Oct 2025 07:11:01 +0200
Subject: [PATCH] review code update to ES arrow function
---
textbased-programms/calendar.js | 10 +++++-----
textbased-programms/gravitation.js | 2 +-
textbased-programms/flipping-a-coin.html | 4 ++--
textbased-programms/drawing-hands.html | 3 ++-
textbased-programms/gravitation.html | 5 ++++-
textbased-programms/dice-simulation.js | 2 +-
textbased-programms/arithmetic-op.js | 2 +-
textbased-programms/dice-simulation.html | 6 +++---
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/textbased-programms/arithmetic-op.js b/textbased-programms/arithmetic-op.js
index 0078520..0db68c9 100644
--- a/textbased-programms/arithmetic-op.js
+++ b/textbased-programms/arithmetic-op.js
@@ -11,5 +11,5 @@
const b = 5;
const c = Math.floor(a/b); // 2
const d = (a/b) | 0;
- terminal.print(c);
+ terminal.print(c, d);
};
\ No newline at end of file
diff --git a/textbased-programms/calendar.js b/textbased-programms/calendar.js
index 5609b99..4dd651d 100644
--- a/textbased-programms/calendar.js
+++ b/textbased-programms/calendar.js
@@ -10,7 +10,7 @@
import {terminal} from "./dfhi.js";
-let Calendar = {
+const Calendar = {
months: [undefined,
"JAN", "FEB", "MÄR", "APR",
"MAI", "JUN", "JUL", "AUG",
@@ -83,14 +83,14 @@
return leapYear;
}
-window.main = function(...argv) {
- let month = Number.parseInt(argv[0]);
- let year = Number.parseInt( argv[1] || 2021 );
+window.main = (...argv) => {
+ const month = Number.parseInt(argv[0]);
+ const year = Number.parseInt( argv[1] || 2021 );
Calendar.month = month;
Calendar.year = year;
- let cal = Calendar.showCalendar();
+ const cal = Calendar.showCalendar();
terminal.printh(cal);
};
diff --git a/textbased-programms/dice-simulation.html b/textbased-programms/dice-simulation.html
index 4fd37f7..7c91586 100644
--- a/textbased-programms/dice-simulation.html
+++ b/textbased-programms/dice-simulation.html
@@ -8,9 +8,9 @@
</head>
<body>
-<p class="description">Simulation eines Würfel</p>
-<label for="run">Klicken Sie auf „Run“ um eine Zahl zu würfeln</label>
-<button name="run" id="run" >Run</button>
+<p class="description">Simulation eines Würfels</p>
+<label for="run">Roll the dice</label>
+<button name="run" id="run" >Roll</button>
<pre id="text-output"></pre>
diff --git a/textbased-programms/dice-simulation.js b/textbased-programms/dice-simulation.js
index e8e512c..e496117 100644
--- a/textbased-programms/dice-simulation.js
+++ b/textbased-programms/dice-simulation.js
@@ -16,7 +16,7 @@
let face = Math.floor(Math.random() * (max - min + 1) + min );
let path = `${IMG_DIR}/${face}.png`;
- let img = `<img width="20px" src="${path}" />`;
+ let img = `<img width="50px" src="${path}" />`;
terminal.clear();
terminal.printh(img);
};
diff --git a/textbased-programms/drawing-hands.html b/textbased-programms/drawing-hands.html
index a0b2ddf..8e73429 100644
--- a/textbased-programms/drawing-hands.html
+++ b/textbased-programms/drawing-hands.html
@@ -8,7 +8,8 @@
</head>
<body>
-Gegenseitige Auruf <input type="text" id="argv" name="argv" />
+<p class="description">Funktionen, die sich gegenseitig aufrufen</p>
+
<button name="run" id="run" >Rerun</button>
diff --git a/textbased-programms/flipping-a-coin.html b/textbased-programms/flipping-a-coin.html
index e4bd8cc..c9a630c 100644
--- a/textbased-programms/flipping-a-coin.html
+++ b/textbased-programms/flipping-a-coin.html
@@ -7,9 +7,9 @@
<link rel="stylesheet" href="dfhi.css" />
</head>
<body>
+<p class="description">Flip A Coin</p>
-<code>main</code>'s arguments: <input type="text" id="argv" name="argv" />
-<button name="run" id="run" >Rerun</button>
+<button name="run" id="run" >Flip</button>
<pre id="text-output"></pre>
diff --git a/textbased-programms/gravitation.html b/textbased-programms/gravitation.html
index c7c2b16..4b5f113 100644
--- a/textbased-programms/gravitation.html
+++ b/textbased-programms/gravitation.html
@@ -8,8 +8,11 @@
</head>
<body>
-<button name="run" id="run" >Rerun</button>
+<p class="description">Programm zum Berechnen der Gravitationskraft zwischen 2 Masse</p>
+
+<label for="argv">Geben Sie das Gewicht von 2 Massen (in Kg) und die Distanz (in meter) ein!</label>
<input type="text" id="argv" name="argv" />
+<button name="run" id="run" >Rerun</button>
<pre id="text-output"></pre>
<script type="module" src="gravitation.js"></script>
diff --git a/textbased-programms/gravitation.js b/textbased-programms/gravitation.js
index 528efbc..a34997c 100644
--- a/textbased-programms/gravitation.js
+++ b/textbased-programms/gravitation.js
@@ -17,5 +17,5 @@
const mass2 = Number(argv[1]);
const r = Number(argv[2]);
const force = G * mass1 * mass2 / (r*r);
- terminal.printh(force);
+ terminal.printh(`${force} N`);
};
--
Gitblit v1.10.0