/
tests.php
59 lines (46 loc) · 1.38 KB
/
tests.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
function __autoload($class_name) {
include $class_name . '.php';
}
/**
* Palindrome test cases
*/
echo "---------------PALINDROMOS-----------------------------<br>";
$cases = [ "Ana", "se van sus naves", "Esto no es un palíndromo"];
foreach ($cases as $case) {
if(Palindrome::isPalindrome($case))
echo "<strong>" . $case . "</strong> Es un Palindromo<br>";
else
echo "<strong>" . $case . "</strong> No es un Palindromo<br>";
}
/**
* Find repeated number
*/
echo "<br>---------------FIND REPEATED NUMBER IN ARRAY-------------------<br>";
$array1 = [1, 4, 1, 3, 2, 5];
$array2 = [3, 1, 2, 2];
echo FindRepeated::find($array1) . '<br>';
echo FindRepeated::find($array2) . '<br>';
/**
* Recipe
*/
echo "<br>---------------FIND THE RECIPE-------------------<br>";
$recipe1 = new Recipe(12);
echo $recipe1->out();
$recipe2 = new Recipe(7);
echo $recipe2->out();
// echo Recipe::findRecipe(12);
// echo Recipe::findRecipe(7);
/**
* Design Patterns
* PROBLEMA: Contar el numero de veces que se llama a un metodo especifico
* SOLUCION: Para solucionar este problema utilizaremos el patron de diseño Singleton. Es el mas adecuado para este
* ya que consiste en crear una sola instancia de una clase
*/
echo "<br>---------------DESIGN PATTERNS-------------------<br>";
$sing = Singleton::getInstance();
$sing->call();
$sing->call();
$sing->call();
$sing->call();
echo $sing->count();