aufgabe vom 24-12-4 (v1)
This commit is contained in:
144
progp/24-12-4/edicer.html
Normal file
144
progp/24-12-4/edicer.html
Normal file
@@ -0,0 +1,144 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>eDicer</title>
|
||||
<style>
|
||||
/* Allgemeine Reset-Styles */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* Hintergrundfarbe und allgemeines Layout */
|
||||
body {
|
||||
font-family: 'Arial', sans-serif;
|
||||
background-color: #f7f7f7;
|
||||
color: #333;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 100%;
|
||||
max-width: 800px;
|
||||
padding: 20px;
|
||||
background-color: #fff;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* Header Styling */
|
||||
header {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
header h1 {
|
||||
font-size: 36px;
|
||||
color: #007BFF;
|
||||
}
|
||||
|
||||
header p {
|
||||
font-size: 18px;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
/* Formular Styling */
|
||||
.form-section {
|
||||
margin-bottom: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
label {
|
||||
font-size: 18px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 80%;
|
||||
padding: 10px;
|
||||
margin-bottom: 20px;
|
||||
font-size: 16px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
transition: border-color 0.3s;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
border-color: #007BFF;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 12px 24px;
|
||||
background-color: #007BFF;
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
button:active {
|
||||
background-color: #004085;
|
||||
}
|
||||
|
||||
/* Ergebnis Styling */
|
||||
.ergebnisse {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#ergebnis {
|
||||
font-size: 20px;
|
||||
color: #007BFF;
|
||||
margin-top: 20px;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
/* Styling für die Würfelergebnisse */
|
||||
.w {
|
||||
width: 50px;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
footer {
|
||||
text-align: center;
|
||||
margin-top: 30px;
|
||||
font-size: 14px;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
footer p {
|
||||
font-style: italic;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form id="eingabe_wuerfel">
|
||||
<label>Wie oft soll geworfen werden?</label>
|
||||
<input type="number" id="anzahl_wuerfel" min="1" name="anzahl_wuerfel"><br>
|
||||
<button type="submit" id="submit_eingabe">Würfeln</button><br>
|
||||
</form>
|
||||
|
||||
<label id="ergebnis"></label>
|
||||
|
||||
<script src="edicer.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
36
progp/24-12-4/edicer.js
Normal file
36
progp/24-12-4/edicer.js
Normal file
@@ -0,0 +1,36 @@
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
var anzahlWuerfelInput = document.getElementById("anzahl_wuerfel");
|
||||
var ergebnisLabel = document.getElementById("ergebnis");
|
||||
|
||||
// Initialer Text
|
||||
//ergebnisLabel.innerHTML = "moin";
|
||||
|
||||
// Event Listener für den Submit-Button
|
||||
document.getElementById("submit_eingabe").addEventListener("click", function(event) {
|
||||
// Verhindern, dass das Formular abgeschickt und die Seite neu geladen wird
|
||||
event.preventDefault();
|
||||
|
||||
// Anzahl der Würfel aus dem Input-Feld holen
|
||||
var anzahlWuerfel = parseInt(anzahlWuerfelInput.value);
|
||||
|
||||
// Überprüfen, ob der Wert gültig ist
|
||||
if (isNaN(anzahlWuerfel) || anzahlWuerfel < 1) {
|
||||
ergebnisLabel.innerHTML = "Bitte eine gültige Anzahl an Würfeln eingeben.";
|
||||
return;
|
||||
}
|
||||
|
||||
// Leeres Ergebnis vorbereiten
|
||||
var ergebnisseHTML = "";
|
||||
|
||||
// Würfeln für die angegebene Anzahl der Würfel
|
||||
for (var i = 0; i < anzahlWuerfel; i++) {
|
||||
var augen = Math.floor(Math.random() * 6) + 1; // Zufallszahl zwischen 1 und 6
|
||||
|
||||
// HTML für jedes Würfelergebnis erstellen
|
||||
ergebnisseHTML += `${i+1}. <img class='w' src='../bilder/${augen}.png' alt='${augen} Augen'>`;
|
||||
}
|
||||
|
||||
// Die Würfelergebnisse anzeigen
|
||||
ergebnisLabel.innerHTML = ergebnisseHTML;
|
||||
});
|
||||
});
|
||||
63
progp/24-12-4/edicer.php
Normal file
63
progp/24-12-4/edicer.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>eDicer</title>
|
||||
<style>
|
||||
.text-bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.w {
|
||||
width: 10%;
|
||||
}
|
||||
.ausgabe{
|
||||
margin: 12px 0;
|
||||
padding: 8px;
|
||||
background-color: #333;
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
.board {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form action="edicer.php">
|
||||
<label>Wie oft soll gewürfelt werden?</label>
|
||||
<input type="number" min="1" name="anzahl_wuerfel"><br>
|
||||
<button type="submit">Würfel</button>
|
||||
</form>
|
||||
<label>(Die Ergebnisse werden sortiert wie folgt sortiert: Klein >> Groß</label>
|
||||
<h1>-----------------------------</h1>
|
||||
<div class="board">
|
||||
<?php
|
||||
$augen_array = [];
|
||||
|
||||
$augen = rand(1,6);
|
||||
$anzahl = $_REQUEST['anzahl_wuerfel'];
|
||||
|
||||
// Array füllen
|
||||
for ($i=1; $i<=$anzahl; $i++){
|
||||
$augen = rand(1,6);
|
||||
$augen_array[] = $augen;
|
||||
//echo "<img width = '10%' src = '/bilder/$augen.png' alt='$augen Augen'>\n";
|
||||
}
|
||||
// Array ausgeben
|
||||
/*echo "<pre>";
|
||||
print_r($augen_array);
|
||||
echo"</pre>";
|
||||
*/
|
||||
sort($augen_array);
|
||||
for ($i=0; $i<$anzahl; $i++){
|
||||
echo "<img width = '10%' src = '../bilder/$augen_array[$i].png' alt='$augen_array[$i] Augen'>\n";
|
||||
}
|
||||
$summe = array_sum($augen_array);
|
||||
echo "<div class='ausgabe'>Die Summe der Augenzahlen beträgt $summe</div>";
|
||||
echo "</div>"
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
BIN
progp/bilder/1.png
Normal file
BIN
progp/bilder/1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
BIN
progp/bilder/2.png
Normal file
BIN
progp/bilder/2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
BIN
progp/bilder/3.png
Normal file
BIN
progp/bilder/3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
BIN
progp/bilder/4.png
Normal file
BIN
progp/bilder/4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
BIN
progp/bilder/5.png
Normal file
BIN
progp/bilder/5.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
BIN
progp/bilder/6.png
Normal file
BIN
progp/bilder/6.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
Reference in New Issue
Block a user