-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariable.class.php
More file actions
50 lines (40 loc) · 936 Bytes
/
variable.class.php
File metadata and controls
50 lines (40 loc) · 936 Bytes
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
<?php
// shorthand constants for x and y strings
const x = 'x';
const y = 'y';
/*
* variable - x/y + number
*/
class Variable {
// type of variable - x or y
public $type;
// digit of the variable
public $digit;
/*
* constructor - input x/y and digit number
*/
public function __construct($type, $digit) {
$this->type = $type;
$this->digit = $digit;
}
/*
* returns the variable as a string
*/
public function toString() {
return $this->type . $this->digit;
}
/*
* make a copy of the variable
*/
public function copy() {
return new Variable($this->type, $this->digit);
}
/*
* checks if the variable equals another variable
*/
public function equals($var) {
if (!is_object($var) || !is_a($var, 'Variable')) return false;
if ($this->type == $var->type && $this->digit == $var->digit) return true;
else return false;
}
}