{
        $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>";
Ejemplo n.º 2
0
        return $this->weight;
    }
    function volume($vol_height, $vol_width, $vol_length)
    {
        $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>
Ejemplo n.º 3
0
            <input id="height" name="height" class="form-control" type="text">
          </div>
          <div class="form-group">
            <label for="weight">Enter the Weight: </label>
            <input id="weight" name="weight" class="form-control" type="text">
          </div>
          <button type="submit" class="btn">Submit</button>
        </form>
      </div>
    </body>';
});
$app->get('/parcel', function () {
    $first_parcel = new Parcel($_GET["length"], $_GET["width"], $_GET["height"], $_GET["weight"]);
    $first_parcel->setLength($_GET["length"]);
    $first_parcel->setWidth($_GET["width"]);
    $first_parcel->setHeight($_GET["height"]);
    ?>
      <title>Answers</title>

      <h1> Here are the answers below: </h1>

<?php 
    $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>";
Ejemplo n.º 4
0
    {
        return $this->weight;
    }
    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