public function addScoop($sendIcecreams) { $return = array(); $flavorObject = new Flavor(); $existedIcecreams = array(); $icecreamsFlavors = array(); $icecreams = array(); $priceTotal = 0; foreach ($sendIcecreams as $icecreamNumber => $icecream) { $this->_scoops = 0; $existedFlavors = array(); if (is_array($icecream)) { foreach ($icecream as $key => $flavor) { if ($flavor != ' ') { if ($flavorObject->haveSuchFlavor($flavor)) { $this->_flavors[] = ucfirst($flavor); $this->_scoops++; $icecreamsFlavors[$key] = true; $existedFlavors[] = array_pop($this->_flavors); } else { $icecreamsFlavors[$key] = false; } } } } $cone = new Cone(); $existedFlavors['cone'] = $cone->getCone($this->_scoops); $priceIcecream = $this->getPrice($this->_scoops); $priceTotal += $priceIcecream; $icecreams[$icecreamNumber] = $icecreamsFlavors; $existedIcecreams[$icecreamNumber] = $existedFlavors; } $priceDiscount = $this->getDiscount($existedIcecreams, $priceTotal); $return['prices'] = $priceDiscount; $return['icecreams'] = $icecreams; $return['existingIcecreams'] = $existedIcecreams; return $return; }
/** * Load the list of available containers */ private function createContainers() { //Two different serving vessels Cone::addConeType('Waffle'); Cup::addCupType('5oz'); }
const FLAV3 = 'Strawberry'; const FLAV4 = 'Mint'; const FLAV5 = 'Superman'; public $setScoops; private $typeDessert = "Waffle Cone"; public function availableFlavors() { return "Our flavors, you may choose up to two: " . Cone::FLAV1 . ", " . Cone::FLAV2 . ", " . Cone::FLAV3 . ", " . Cone::FLAV4 . ", " . Cone::FLAV5 . "<br><br>"; } public function getTypeDessert() { return "Type of Dessert: " . $this->typeDessert . "<br>"; } } // Cone $icCone = new Cone(); echo $icCone->getTypeDessert(); echo $icCone->availableFlavors(); //echo $icCone->getFirstFlavor(); //echo $icCone->getSecFlavor(); class Milkshake { const FLAV1 = 'Chocolate'; const FLAV2 = 'Vanilla'; const FLAV3 = 'Strawberry'; const FLAV4 = 'Mint'; const FLAV5 = 'Superman'; const MILK1 = 'Skim'; const MILK2 = 'Two Percent'; const MILK3 = 'Whole'; private $typeDessert = 'Milkshake Cup';
<?php require_once './src/shape.php'; require_once './src/circle.php'; require_once './src/cone.php'; require_once './src/cylinder.php'; $shape1 = new shape(3, 4, "niebieski"); $shape2 = new shape(6, 8, "czerwony"); $shape1->printInfo(); echo $shape1->distance($shape2); $circle1 = new Circle(3, 4, "red", 5); $circle2 = new Circle(6, 8, "blue", 2); $circle1->printInfo(); echo "Odleglosc miedzy srodkami kol = " . $circle1->distance($circle2) . "<br><br>"; echo "Pole kola = " . $circle1->getArea() . "<br><br>"; echo "Obwod kola = " . $circle1->getPir() . "<br><br>"; $cone = new Cone(9, 12, "green", 5, 15); $cone->printInfo(); echo "Pole stozka = " . $cone->getArea() . "<br><br>"; echo "Objetosc stozka = " . $cone->getVol() . "<br><br>"; $cylinder = new Cylinder(12, 16, "green", 10, 20); $cylinder->printInfo(); echo "Pole walca = " . $cylinder->getArea() . "<br><br>"; echo "Objetosc walca = " . $cylinder->getVol() . "<br><br>";