} elseif ($_GET[$property] == "") { die("{$property} was not defined"); } } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Parcel Printout</title> </head> <body> <?php $customer_parcel = new Parcel($_GET["length"], $_GET["width"], $_GET["height"], $_GET["weight"]); $length = $customer_parcel->getLength(); $width = $customer_parcel->getWidth(); $height = $customer_parcel->getHeight(); $weight = $customer_parcel->getWeight(); $volume = $customer_parcel->volume(); $cost = $customer_parcel->costToShip(); echo "<p> Parcel length: {$length} </P>"; echo "<p> Parcel width: {$width} </P>"; echo "<p> Parcel height: {$height} </P>"; echo "<p> Parcel weight: {$weight} </P>"; echo "<p> Parcel volume: {$volume} </P>"; echo "<p> Parcel cost: \${$cost} </P>"; ?> </body> </html>
} $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>"; echo "<p> Height: " . $shoes->getHeight() . " inches. </p>"; echo "<p> Weight: " . $shoes->getWeight() . " pounds. </p>"; echo "<p> Volume: " . $shoes->volume() . " cubed inches. </p>"; echo "<p> Cost to ship: \$" . $shoes->costToShip() . "</p>"; } ?> </div> </body> </html>
function costToShip() { return 0.0015 * ($this->volume() * $this->weight); } } $partyParcel = new Parcel($_GET["height"], $_GET["width"], $_GET["length"], $_GET["weight"]); ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> <title>PACKAGE INFO</title> </head> <body> <?php if (empty($partyParcel->getHeight()) || empty($partyParcel->getWidth()) || empty($partyParcel->getLength()) || empty($partyParcel->getWeight())) { echo "You missed a parameter"; } else { echo "<h1>HEIGHT: " . $partyParcel->getHeight() . "</h1>"; echo "<h1>WIDTH: " . $partyParcel->getWidth() . "</h1>"; echo "<h1>LENGTH: " . $partyParcel->getLength() . "</h1>"; echo "<h1>WEIGHT: " . $partyParcel->getWeight() . "</h1>"; echo "<h1>VOLUME: " . $partyParcel->volume() . "</h1>"; setlocale(LC_MONETARY, 'en_US'); echo "<h1>COST 2 SHIP: " . money_format('%(#1n', $partyParcel->costToShip()) . "</h1>"; } ?> </body> </html>
function costToShip() { return $this->getVolume() * 0.6; } } ?> <!DOCTYPE html> <html> <head> <title>Shipping Details Page</title> </head> <body> <h1>Shipping Costs</h1> <?php $get_weight = $_GET["weight"]; $get_length = $_GET["length"]; $get_width = $_GET["width"]; $get_height = $_GET["height"]; $new_parcel = new Parcel($_GET["weight"], $_GET["length"], $_GET["width"], $_GET["height"]); $get_volume = $new_parcel->getVolume(); $get_price = $new_parcel->costToShip(); if (!$get_weight || !$get_length || !$get_height || !$get_width) { echo "<p>You must enter all data fields to calculate a cost! Try again!</p>"; } else { echo "<p>Your parcel weight is: {$get_weight} </p>\n <p>Your parcel length is: {$get_length} </p>\n <p>Your parcel width is: {$get_width} </p>\n <p>Your parcel height is: {$get_height} </p>\n <p>Your parcel volume is: {$get_volume} </p>\n <p>Your cost to ship: \${$get_price} </p>"; } ?> </body> </html>
$first_parcel_length = $first_parcel->getLength(); if ($first_parcel->getlength() == 0) { echo "<p>Length: A number please!</p>"; } else { echo "<p>Length: {$first_parcel_length} (ft)</p>"; } $first_parcel_width = $first_parcel->getWidth(); if ($first_parcel->getWidth() == 0) { echo "<p>Width: A number please!</p>"; } else { echo "<p>Width: {$first_parcel_width} (ft)</p>"; } $first_parcel_height = $first_parcel->getHeight(); if ($first_parcel->getHeight() == 0) { echo "<p>Height: A number please!</p>"; } else { echo "<p>Height: {$first_parcel_height} (ft)</p>"; } $first_parcel_weight = $first_parcel->getWeight(); if ($first_parcel->getWeight() == 0) { echo "<p>Weight: A number please!</p>"; } else { echo "<p>Weight: {$first_parcel_weight} (lbs)</p>"; } $first_parcel_volume = $first_parcel->volume($first_parcel_length, $first_parcel_width, $first_parcel_height); echo "<p>Volume: {$first_parcel_volume} (cubic ft)</p>"; $first_parcel_ship_cost = $first_parcel->costToShip($first_parcel_weight); echo "<p>Shipping Cost:\${$first_parcel_ship_cost}</p>"; return ""; }); return $app;
$total_volume = $this->volume(); return $total_volume * $this->weight / 100000; } } $new_parcel = new Parcel($_GET["length"], $_GET["height"], $_GET["width"], $_GET["weight"]); ?> <!DOCTYPE html> <html> <head> <title>Parcel Shipping Cost Homepage</title> </head> <body> <h1>Your Parcel Shipping Cost</h1> <ul> <?php $total_length = $new_parcel->getLength(); $total_height = $new_parcel->getHeight(); $total_width = $new_parcel->getWidth(); $total_weight = $new_parcel->getWeight(); $total_volume = $new_parcel->volume(); $total_cost = $new_parcel->costToShip(); echo "<li> Cost: \${$total_cost} </li>"; echo "<li> Volume: {$total_volume} cubic inches </li>"; echo "<li> Dimensions: {$total_length} X {$total_height} X {$total_width} inches </li>"; echo "<li> Weight: {$total_weight} pounds</li>"; ?> </ul> </body> </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(); $parcel_length = $parcel->getLength(); $parcel_volume = $parcel->volume($parcel_height, $parcel_width, $parcel_length); $parcel_weight = $parcel->getWeight(); $parcel_cost = $parcel->costToShip($parcel_volume, $parcel_weight); $parcel_info = array($parcel_height, $parcel_width, $parcel_length, $parcel_weight); foreach ($parcel_info as $input) { $completed = 0; if ($input == 0) { $completed = $completed + 1; } else { $completed = $completed; } } if ($completed != 0) { echo "<h2>Please fill in all form fields.</h2>"; } else { echo "<li> Height: {$parcel_height} inches </li>\n <li> Width: {$parcel_width} inches </li>\n <li> Length: {$parcel_length} inches </li>\n <li> Volume: {$parcel_volume} cubic inches</li>\n <li> Weight: {$parcel_weight} pounds</li>\n <h2>Total cost to ship: \${$parcel_cost} </h2>\n "; } ?>
<input id="width" name="width" type="number"> <label for="height">Height</label> <input id="height" name="height" type="number"> <label for="weight">Weight</label> <input id="weight" name="weight" type="number"> <button type="submit">Calculate Cost</button> </form> <div> <h3>Your Parcel:</h3> <ul><?php $curLength = $parcel->getLength(); $curWidth = $parcel->getWidth(); $curHeight = $parcel->getHeight(); $curWeight = $parcel->getWeight(); $curVolume = $parcel->volume(); $curCost = $parcel->costToShip(); if ($curLength && $curWidth && $curHeight && $curWeight && $curVolume && $curCost) { echo "<li>Length: {$curLength} </li>"; echo "<li>Width: {$curWidth} </li>"; echo "<li>Height: {$curHeight} </li>"; echo "<li>Weight: {$curWeight} </li>"; echo "<li>Volume: {$curVolume} </li>"; echo "<li>Total Cost: {$curCost} </li>"; } else { echo "<p>Please enter a value for all fields</p>"; } ?> </ul> </div> <script type='text/javascript' id="__bs_script__">//<![CDATA[ document.write("<script async src='http://HOST:3000/browser-sync/browser-sync-client.2.11.1.js'><\/script>".replace("HOST", location.hostname));
} } $newParcel = new Parcel($_GET['height'], $_GET['width'], $_GET['length'], $_GET['weight']); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Parcels</title> </head> <body> <h1>Your Parcel Details:</h1> <?php if ($newParcel->getHeight() > 0 && $newParcel->getWidth() > 0 && $newParcel->getLength() > 0 && $newParcel->getWeight() > 0) { $show_height = $newParcel->getHeight(); $show_width = $newParcel->getWidth(); $show_length = $newParcel->getLength(); $show_weight = $newParcel->getWeight(); $show_volume = $newParcel->volume(); $show_cost = $newParcel->costToShip(); echo "<p>Your package is {$show_height} High, {$show_width} Wide, {$show_length} Long, {$show_weight} Heavy</p>"; echo "<p>The volume is {$show_volume}</p>"; echo "<p>Shipping cost is: {$show_cost}</p>"; } else { echo "<p> Something is wrong</p>"; } ?> </body> </html>
<!DOCTYPE html> <html> <head> <title>Send a parcel</title> </head> <body> <h1>Parcel site!</h1> <ul> <?php $parcel_weight = $_GET["weight"]; $parcel_height = $_GET["height"]; $parcel_width = $_GET["width"]; $parcel_length = $_GET["length"]; $new_parcel = new Parcel($parcel_weight, $parcel_height, $parcel_width, $parcel_length); $get_volume = $new_parcel->volume(); $get_cost = $new_parcel->costToShip(); if (empty($parcel_weight) || empty($parcel_height) || empty($parcel_width) || empty($parcel_length)) { echo "please fill all form fields with numeric values"; } else { echo "<p> Weight: " . $parcel_weight . "</p>"; echo "<p> Height: " . $parcel_height . "</p>"; echo "<p> Width: " . $parcel_width . "</p>"; echo "<p> Length: " . $parcel_length . "</p>"; echo "<p> Volume: " . $get_volume . "</p>"; echo "<p> Cost to Ship: " . $get_cost . "</p>"; } ?> </ul> </body> </html>
return $this->length * $this->width * $this->height; } // Calculate the cost to ship function costToShip() { return $this->weight * 0.8; } } $usrPackage = new Parcel($_GET["weight"], $_GET["length"], $_GET["width"], $_GET["height"], $_GET["carrier"]); ?> <!DOCTYPE html> <html> <head> <title>Shipping Calculator</title> </head> <body> <h1>Ship Stuff</h1> <ul> <?php $shippingPrice = $usrPackage->costToShip(); $packageVolume = $usrPackage->volume(); echo "<li> Package:</li>"; echo "<ul>"; echo "<li> Cost to Ship: \${$shippingPrice} </li>"; echo "<li> {$packageVolume} </li>"; echo "</ul>"; ?> </ul> </body> </html>
return $this->weight; } } $my_parcel = new Parcel($_GET["width"], $_GET["length"], $_GET["height"], $_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"> <title>Shipping Cost</title> </head> <body> <div class="container"> <?php $shippingCost = $my_parcel->costToShip(); $parcelWidth = $my_parcel->getWidth(); $parcelLength = $my_parcel->getLength(); $parcelHeight = $my_parcel->getHeight(); $parcelWeight = $my_parcel->getWeight(); if ($parcelWidth == "" || $parcelLength == "" || $parcelHeight == "" || $parcelWeight == "") { echo "<h1>Please fill out all fields!</h1>"; } else { echo "<h1>This will be your shipping cost:</h1>"; echo "<h3>\${$shippingCost}</h3>"; echo "<h4>Your package:</h4>"; echo "<p>Width: {$parcelWidth}</p>"; echo "<p>Length: {$parcelLength}</p>"; echo "<p>Height: {$parcelHeight}</p>"; echo "<p>Weight: {$parcelWeight}</p>"; }
.hidden { display: none; } </style> </head> <body> <div class="container"> <div class="row"> <div class="col-sm-6"> <h1>Your parcel:</h1> <ul> <?php if (!$isParcel) { echo "<h3>Please add a numerical value for " . $error . ".</h3>"; } else { $dim_price = money_format('%(#10.2n', $your_parcel->costToShip()); echo "<li>Length: " . $your_parcel->getLength() . "</li>\n"; echo "<li>Width: " . $your_parcel->getWidth() . "</li>\n"; echo "<li>Height: " . $your_parcel->getHeight() . "</li>\n"; echo "<li>Weight: " . $your_parcel->getWeight() . "</li>\n"; echo "<li><strong>Volume: " . $your_parcel->volume() . "</strong></li>\n"; echo "<li>Total Cost:" . $dim_price . "</li>\n"; } ?> </ul> </div> <div class="col-sm-6"> <?php if (!$isParcel) { echo "<img class='img-responsive hidden' src='images/box.jpg'>"; } else {
} function getVolume() { return $this->length * $this->width * $this->height; } } ?> <html> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> <title>Parcel Results</title> </head> <body> <div class="container"> <h1>Your Parcel's information</h1> <!-- <?php $parcel_weight = $user_parcel->getWeight(); ?> --> <?php if ($valid_parcel == true) { echo "<p>Weight: " . $user_parcel->getWeight() . " </p>\n <p>Length: " . $user_parcel->getLength() . "</p>\n <p>Width: " . $user_parcel->getWidth() . " </p>\n <p>Height: " . $user_parcel->getHeight() . " </p>\n <p>Volume: " . $user_parcel->getVolume() . " </p>\n <p>Your cost to ship: \$" . $user_parcel->costToShip() . " </p>"; } else { echo "<h4>This is not a valid parcel!</h4>"; } ?> </div> </body> </html>
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/Parcel.php"; $app = new Silex\Application(); $app->get("/", function () { return "\n <!DOCTYPE html>\n <html>\n <head>\n <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'>\n <title>Parcel Price</title>\n </head>\n <body>\n <div class='container'>\n <h1>How much will it cost to ship this Parcel?</h1>\n <p>Complete all fields in the form below to calculate the cost to ship your Parcel.</p>\n <form action='price_parcel'>\n <div class='form-group'>\n <label for='height'>Height (in inches):</label>\n <input id='height' name='height' class='form-control' type='number'>\n </div>\n <div class='form-group'>\n <label for='length'>Length (in inches):</label>\n <input id='length' name='length' class='form-control' type='number'>\n </div>\n <div class='form-group'>\n <label for='width'>Width (in inches):</label>\n <input id='width' name='width' class='form-control' type='number'>\n </div>\n <div class='form-group'>\n <label for='weight'>Weight (in ounces):</weight>\n <input id='weight' name='weight' class='form-control' type='number'>\n </div>\n <button type='submit' class='btn-success'>Name That Price!</button>\n </form>\n </div>\n </body>\n </html>\n "; }); $app->get("/price_parcel", function () { $my_parcel = new Parcel($_GET['height'], $_GET['length'], $_GET['width'], $_GET['weight']); $size = $my_parcel->volume(); $ship_weight = $my_parcel->costToShip(); if ($size != 0 && $ship_weight != 0) { return "<h3>A parcel with a volume of {$size} inches, will cost \${$ship_weight} to ship.</h3>"; } else { return "<h3>Error: One or more fields were blank</h3>"; } }); return $app;
<head> <title></title> </head> <body> <ul> <?php $theString = "<li> The Parcel Length is: "; $theString .= $a->getLength(); $theString .= "</li>"; $theString .= "<li> The Parcel Width is: "; $theString .= $a->getWidth(); $theString .= "</li>"; $theString .= "<li>The Parcel Height is: "; $theString .= $a->getHeight(); $theString .= "</li>"; $theString .= "<li> The Parcel Weight is: "; $theString .= $a->getWeight(); $theString .= "</li>"; $theString .= "<li> The Parcel Volume is: "; $theString .= $a->volume(); $theString .= "</li>"; $theString .= "<li> The Cost to Ship is: "; $theString .= $a->costToShip(); $theString .= "</li>"; echo $theString; ?> </ul> </body> </html>