Esempio n. 1
0
    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>
Esempio n. 2
0
    }
    function getWeight()
    {
        return $this->weight;
    }
    function getVolume()
    {
        return $this->volume;
    }
}
$weight = $_GET["weight"];
$calculator_length = $_GET["length"];
$calculator_width = $_GET["width"];
$calculator_height = $_GET["height"];
$new_parcel = new Parcel($weight);
$new_parcel->volume($calculator_length, $calculator_width, $calculator_height);
?>

<html>
  <head>
    <title></title>
  </head>
  <body>
    <?php 
echo "<h1>" . $new_parcel->getWeight() . "</h1>";
echo "<h1>" . $new_parcel->getVolume() . "</h1>";
?>

  </body>
</html>
Esempio n. 3
0
    }
    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>