-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBicycle.php
41 lines (33 loc) · 976 Bytes
/
Bicycle.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
<?php
class Bicycle
{
var $brand;
var $model;
var $year;
var $description = "Used Bicycle";
var $weight_kg = 0.0;
function name()
{
return "{$this->brand}, {$this->model} ({$this->year})";
}
function weight_lbs()
{
return (floatval($this->weight_kg) * 2.2046226218) . " lbs";
}
function set_weight_lbs($value)
{
$this->weight_kg = floatval($value) / 2.2046226218;
}
}
$bicycle = new Bicycle;
$bicycle->brand = "new";
$bicycle->model = "SDN";
$bicycle->year = 2019;
$bicycle->weight_kg = 75;
const BR = "<br>";
echo "Bicycle Name: {$bicycle->name()}" . BR;
echo "Bicycle Weight (lbs): {$bicycle->weight_lbs()}" . BR;
echo "Bicycle Weight (kg): " . ($bicycle->weight_lbs() / 2.2046226218) . BR;
echo "Bicycle set Weight to 200 lbs: " . ($bicycle->set_weight_lbs(200)) . BR;
echo "Bicycle Weight (lbs): {$bicycle->weight_lbs()}" . BR;
echo "Bicycle Weight (kg): {$bicycle->weight_kg}" . BR;