-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
43 lines (40 loc) · 906 Bytes
/
index.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
<?php
class item {
private $value;
private $d = 0;
function __construct($n){
$this->value = $n;
$this->d |= $n % 3 ? 0 : 1;
$this->d |= $n % 5 ? 0 : 2;
}
function __toString(){
$out = "";
if ($this->d & 1){
$out .= "CUBE";
}
if ($this->d & 2){
$out .= "Systems";
}
if (!$out){
$out = (string) $this->value;
}
return $out;
}
}
class api {
public $items = [];
function __construct($n){
for ($i = 1; $i <= $n; $i++){
array_push($this->items, new item($i));
}
}
function render($line_separator){
$result = [];
foreach ($this->items as $item){
array_push($result, (string) $item);
}
echo implode($line_separator, $result);
}
}
$api = new api(100);
$api->render("\n");