-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparcel.php
More file actions
132 lines (100 loc) · 2.53 KB
/
parcel.php
File metadata and controls
132 lines (100 loc) · 2.53 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
class parcel{
private $width;
private $height;
private $weight;
private $depth;
function __construct($height, $width, $weight, $depth){
$this->width=$width;
$this->height=$height;
$this->weight=$weight;
$this->depth=$depth;
}
function setWidth($new_width){
$float_width= (float) $new_width;
if ($float_width !=0 ){
$formatted_width = number_format($float_width, 2);
$this->width = $formatted_width;
}
}
function getWidth(){
return $this->width;
}
function setHeight($new_height){
$float_number=(float)$new_height;
if($floatnumber !=0){
$formatted_height = number_format($float_height, 2);
$this->height=$formated_price;
}
}
function getHeight(){
return $this->height;
}
function setWeight($new_weight){
$float_number=(float)$new_weight;
if($floatnumber !=0){
$formatted_weight = number_format($float_weight, 2);
$this->weight=$formated_price;
}
}
function getWeight(){
return $this->weight;
}
function setDepth($new_depth){
$float_number=(float)$new_depth;
if($floatnumber !=0){
$formatted_weight = number_format($float_weight, 2);
$this->depth=$formated_price;
}
}
function getDepth(){
return $this->depth;
}
function volume(){
return $this->height * $this->weight * $this->depth;
}
function costOfShipping(){
if ($this->volume() > 4){
echo "<br/>Your shipping cost will be $10";
}
}
}
$parcel1= new parcel($_GET['height'],$_GET['width'],$_GET['weight'],$_GET['depth']);
?>
<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cars</title>
</head>
<body>
<?php
if(empty($_GET['height']) && empty($_GET['width']) && empty($_GET['weight']) && empty($_GET['depth']) ){
echo "Please Fill out all the feilds";
}
elseif(empty($_GET['height']) || empty($_GET['width']) || empty($_GET['weight']) || empty($_GET['depth'])){
echo "Please Fill out the empty feild";
}
else{
echo "<h1>You entered</h1>";
echo "<h3>height</h3>";
$height=$parcel1->getHeight();
echo $height;
echo "<h3>Width</h3>";
$width=$parcel1->getWidth();
echo $width;
echo "<h3>Depth</h3>";
$depth=$parcel1->getDepth();
echo $depth;
echo "<h3>Weight</h3>";
$weight=$parcel1->getWeight();
echo $weight;
echo "<br/>The Volume of the package is:";
$test= $parcel1->volume();
echo $test;
$costofshipping=$parcel1->costOfShipping();
echo $costofshipping;
}
?>
</body>
</html>