-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPieceQuantik.php
109 lines (89 loc) · 2.49 KB
/
PieceQuantik.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
class PieceQuantik
{
public const WHITE = 0;
public const BLACK = 1;
public const VOID = 0;
public const CUBE = 1;
public const CONE = 2;
public const CYLINDRE = 3;
public const SPHERE = 4;
protected int $forme;
protected int $couleur;
//constructeur
private function __construct(int $forme, int $couleur)
{
$this->forme = $forme;
$this->couleur = $couleur;
}
public static function initVoid(): PieceQuantik
{
return new PieceQuantik(self::VOID, self::WHITE);
}
public static function initWhiteCube(): PieceQuantik
{
return new PieceQuantik(self::CUBE, self::WHITE);
}
public static function initBlackCube(): PieceQuantik
{
return new PieceQuantik(self::CUBE, self::BLACK);
}
public static function initWhiteCone(): PieceQuantik
{
return new PieceQuantik(self::CONE, self::WHITE);
}
public static function initBlackCone(): PieceQuantik
{
return new PieceQuantik(self::CONE, self::BLACK);
}
public static function initWhiteCylindre(): PieceQuantik
{
return new PieceQuantik(self::CYLINDRE, self::WHITE);
}
public static function initBlackCylindre(): PieceQuantik
{
return new PieceQuantik(self::CYLINDRE, self::BLACK);
}
public static function initWhiteSphere(): PieceQuantik
{
return new PieceQuantik(self::SPHERE, self::WHITE);
}
public static function initBlackSphere(): PieceQuantik
{
return new PieceQuantik(self::SPHERE, self::BLACK);
}
public function getForme(): int
{
return $this->forme;
}
public function getCouleur(): int
{
return $this->couleur;
}
public function __toString(): string
{
// return "[".self::Forme_String[$this->forme].",".self::Couleur_String[$this->couleur]."]";
if ($this->couleur == 0) {
$c = 'Blanc';
} else {
$c = 'Noir';
}
if ($this->forme == 0 && $c == 'Blanc') {
$f = 'Vide';
$c = '';
} else if ($this->forme == 0) {
$f = 'Vide';
} else if ($this->forme == 1) {
$f = 'Cube';
} else if ($this->forme == 2) {
$f = 'Cone';
} else if ($this->forme == 3) {
$f = 'Cylindre';
} else if ($this->forme == 4) {
$f = 'Sphere';
}
$s = '<p>' . $f . " " . $c . '</p>';
return $s;
}
}
?>