$this->weight = $weight; } function volume() { return $this->length * $this->width * $this->height; } function costToShip() { return $this->height + $this->width + ($this->length + $this->weight); } } $shoes = new Parcel(0, 0, 0, 0); $shoes->setLength($_GET["length"]); $shoes->setWidth($_GET["width"]); $shoes->setHeight($_GET["height"]); $shoes->setWeight($_GET["weight"]); ?> <!DOCTYPE html> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> <title>Parcel shipping cost</title> </head> <body> <div class="container"> <h1>Shipping cost:</h1> <?php if (empty($shoes->getLength()) || empty($shoes->getWidth()) || (empty($shoes->getHeight()) || empty($shoes->getWeight()))) { echo "<p>Please complete empty fields.</p>"; } else { echo "<p> Length: " . $shoes->getLength() . " inches.</p>"; echo "<p> Width: " . $shoes->getWidth() . " inches. </p>";
} function volume() { return $this->height * $this->weight * $this->width; } function callToShip() { $floated_shipping = (double) $this->weight * 1000 / $this->height; $formatted_shipping = number_format($floated_shipping, 2); return $formatted_shipping; } } $new_parcel = new Parcel(); $new_parcel->setHeight($height); $new_parcel->setWidth($width); $new_parcel->setWeight($weight); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/css/materialize.min.css"> </head> <body> <div class="container"> <ul> <?php $new_height = $new_parcel->getHeight(); $new_width = $new_parcel->getWidth();
{ $volume = $vol_height * $vol_width * $vol_length; return $volume; } function costToShip($volume, $weight) { $shipping_cost = $volume * $weight / 500; $formatted_price = number_format($shipping_cost, 2); return $formatted_price; } } $parcel = new Parcel(); $parcel->setHeight($_GET["height"]); $parcel->setWidth($_GET["width"]); $parcel->setLength($_GET["length"]); $parcel->setWeight($_GET["weight"]); ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> <meta charset="utf-8"> <title></title> </head> <body> <h1>Parcel</h1> <ul> <?php $parcel_height = $parcel->getHeight(); $parcel_width = $parcel->getWidth();
<?php class Parcel { public $weight; public $destinationAddress; public $destinationCountry; public function setWeight($weight) { echo "weight set to: " . $weight . "\n"; $this->weight = $weight; return $this; } public function setCountry($country) { echo "destination country is: " . $country . "\n"; $this->destinationCountry = $country; return $this; } } //end of Parcel class $myparcel = new Parcel(); $myparcel->setWeight(5)->setCountry('Peru');