This repository was archived by the owner on Jun 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathobjects.php
More file actions
100 lines (83 loc) · 1.74 KB
/
objects.php
File metadata and controls
100 lines (83 loc) · 1.74 KB
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
<?php
class Shape
{
private $id = '0';
private $points = array();
private $contract_date = "";
private $ratified_date = "";
private $baseprice = 0; //Baseprice from database
private $address = ""; //Hosue address
private $remarks = ""; //comments from database
function __construct($id){
$this->id = $id;
}
public function __set($property, $value) {
if (property_exists($this, $property))
{
$this->$property = $value;
}
}
public function __get($property) {
if (property_exists($this, $property)) {
return $this->$property;
}
}
public function getStatus()
{
if ( (!(empty($this->ratified_date))) && (!(empty($this->contract_date))) )
{return "Sold"; }
else if (!(empty($this->ratified_date)))
{return "Hold"; }
else
{return "Available"; }
}
public function addPoint($point)
{
array_push($this->points,$point);
}
public function pointsToString()
{
$firstTime = true;
$str = "";
foreach($this->points as $thisPoint)
{
if (!($firstTime))
{
$str .= ",";
}
$str .= $thisPoint->__get(x) . "," . $thisPoint->__get(y);
$firstTime = false;
}
return rtrim($str, ",");
}
public function to_json() {
$string = "{\"id\":\"";
$string .= $this->id;
$string .= "\",\"points\":[";
$firstTime = true;
foreach($this->points as $thisPoint)
{
if ($firstTime == false)
{$string .= ",";}
$string .= "{\"x\":".$thisPoint->__get(x).",\"y\":".$thisPoint->__get(y)."}";
$firstTime = false;
}
$string .= "]}";
return $string;
}
}
class Point
{
private $x = '0';
private $y = '0';
function __construct($x, $y){
$this->x = $x;
$this->y = $y;
}
public function __get($property) {
if (property_exists($this, $property)) {
return $this->$property;
}
}
}
?>