Add dice PHP exercise.

This commit is contained in:
Nicolás A. Ortega Froysa 2022-11-17 17:12:51 +01:00
parent 55ee7e36f9
commit 0c0702fc77
7 changed files with 119 additions and 0 deletions

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>Dice</title>
</head>
<body>
<?php
$num_dice = rand(1,10);
?>
<h1><?= $num_dice ?> dados</h1>
<?php
$rolls = [];
$max = -1;
for($i = 0; $i < $num_dice; $i++) {
$rolls[$i] = rand(1,6);
if($rolls[$i] > $max)
$max = $rolls[$i];
?>
<img src="imgs/<?= $rolls[$i] ?>.svg" />
<?php
}
?>
<p>El valor más grande obtenido es <b><?= $max ?></b>.</p>
<p>Última modificación de esta página: <?= date('Y-m-d', filemtime(__FILE__)) ?>
</body>
</html>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
width="140" height="140" viewBox="-10 -10 140 140">
<rect x="0" y="0" width="120" height="120" rx="10" ry="10"
fill="#E0E0E0" stroke="black" stroke-width="5" />
<circle cx="60" cy="62" r="9" fill="white" />
<circle cx="60" cy="60" r="9" fill="black" />
</svg>

After

Width:  |  Height:  |  Size: 382 B

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
width="140" height="140" viewBox="-10 -10 140 140">
<rect x="0" y="0" width="120" height="120" rx="10" ry="10"
fill="#E0E0E0" stroke="black" stroke-width="5" />
<circle cx="30" cy="32" r="9" fill="white" />
<circle cx="30" cy="30" r="9" fill="black" />
<circle cx="90" cy="92" r="9" fill="white" />
<circle cx="90" cy="90" r="9" fill="black" />
</svg>

After

Width:  |  Height:  |  Size: 479 B

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
width="140" height="140" viewBox="-10 -10 140 140">
<rect x="0" y="0" width="120" height="120" rx="10" ry="10"
fill="#E0E0E0" stroke="black" stroke-width="5" />
<circle cx="30" cy="32" r="9" fill="white" />
<circle cx="30" cy="30" r="9" fill="black" />
<circle cx="60" cy="62" r="9" fill="white" />
<circle cx="60" cy="60" r="9" fill="black" />
<circle cx="90" cy="92" r="9" fill="white" />
<circle cx="90" cy="90" r="9" fill="black" />
</svg>

After

Width:  |  Height:  |  Size: 576 B

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
width="140" height="140" viewBox="-10 -10 140 140">
<rect x="0" y="0" width="120" height="120" rx="10" ry="10"
fill="#E0E0E0" stroke="black" stroke-width="5" />
<circle cx="30" cy="32" r="9" fill="white" />
<circle cx="30" cy="30" r="9" fill="black" />
<circle cx="30" cy="92" r="9" fill="white" />
<circle cx="30" cy="90" r="9" fill="black" />
<circle cx="90" cy="32" r="9" fill="white" />
<circle cx="90" cy="30" r="9" fill="black" />
<circle cx="90" cy="92" r="9" fill="white" />
<circle cx="90" cy="90" r="9" fill="black" />
</svg>

After

Width:  |  Height:  |  Size: 673 B

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
width="140" height="140" viewBox="-10 -10 140 140">
<rect x="0" y="0" width="120" height="120" rx="10" ry="10"
fill="#E0E0E0" stroke="black" stroke-width="5" />
<circle cx="30" cy="32" r="9" fill="white" />
<circle cx="30" cy="30" r="9" fill="black" />
<circle cx="30" cy="92" r="9" fill="white" />
<circle cx="30" cy="90" r="9" fill="black" />
<circle cx="60" cy="62" r="9" fill="white" />
<circle cx="60" cy="60" r="9" fill="black" />
<circle cx="90" cy="32" r="9" fill="white" />
<circle cx="90" cy="30" r="9" fill="black" />
<circle cx="90" cy="92" r="9" fill="white" />
<circle cx="90" cy="90" r="9" fill="black" />
</svg>

After

Width:  |  Height:  |  Size: 770 B

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
width="140" height="140" viewBox="-10 -10 140 140">
<rect x="0" y="0" width="120" height="120" rx="10" ry="10"
fill="#E0E0E0" stroke="black" stroke-width="5" />
<circle cx="30" cy="32" r="9" fill="white" />
<circle cx="30" cy="30" r="9" fill="black" />
<circle cx="30" cy="62" r="9" fill="white" />
<circle cx="30" cy="60" r="9" fill="black" />
<circle cx="30" cy="92" r="9" fill="white" />
<circle cx="30" cy="90" r="9" fill="black" />
<circle cx="90" cy="32" r="9" fill="white" />
<circle cx="90" cy="30" r="9" fill="black" />
<circle cx="90" cy="62" r="9" fill="white" />
<circle cx="90" cy="60" r="9" fill="black" />
<circle cx="90" cy="92" r="9" fill="white" />
<circle cx="90" cy="90" r="9" fill="black" />
</svg>

After

Width:  |  Height:  |  Size: 867 B