-
Notifications
You must be signed in to change notification settings - Fork 0
/
third.hack
62 lines (50 loc) · 1.04 KB
/
third.hack
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
namespace DruiD628\Test;
<<__EntryPoint>>
function third(): void
{
echo "welcome to Hack!\n\n";
\printf("DruiD628 . hack\n");
$x = new Testola("stuff and thangs", false);
try {
echo $x->getMessage() . "\n\n\n";
} catch (\Exception $e) {
echo "I guess you done fudged up!\n\n\n";
}
exit(0);
}
class Testola
{
public bool $active;
public string $message;
public function __construct(string $message, bool $active = true)
{
$this->active = $active;
$this->message = $message;
}
public function setMessage(string $message): notreturn
{
$this->message = $message;
}
public function getMessage(): string
{
if (!$this->isActive()) {
throw new \Exception("Problem boss!");
}
return $this->message;
}
public function isActive(): bool
{
return $this->active;
}
}
/**
* OUTPUT:
* $ hhvm third.hack
* welcome to Hack!
*
* DruiD628 . hack
* I guess you done fudged up!
*
*
* $
*/