Skip to content

GhostMech/FoodOrder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FoodOrder

Testing ground for the Food and Order classes.

Food Class

This class implements the FoodInterface interface. It uses these methods:

  • name()
  • price()
  • getName() (Accessor from the FoodInterface interface)
  • getPrice() (also from the FoodInterface interface)

Order Class

This class is composed of Food objects. It uses these methods:

  • addItem()
  • removeItem()
  • getItems() (returns an array of Food objects)
  • getNames()
  • getPrices()
  • getAllNamesAndPrices()
  • rawTotal()

Here is an example using the Order class:

<?php
namespace GMH;

// Require the Order class
require_once 'Order.php';

$order = new Order();

// Use method chaining
$fries = new Food();
$fries->name("French Fries")->price('3.50');
$pizza = new Food();
$pizza->name('Pepperoni Pizza')->price('11.95');

$order->addItem($fries)->addItem($pizza);

// Raw Total:
echo $order->rawTotal();

// Set a discount and a tax rate
$order->discount(10)->tax(8);

// Get the total after discount and tax
echo $order->totalWithTax();

?>

About

Testing ground for the Food and Order classes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages