Example #1
0
 /**
  * Hozzá adja, elmenti az adatbázisban az új termék adatait.
  *
  * @param Product $product
  * @return Exception|string
  */
 public function productAddStore($product)
 {
     //die("temrék neve: " . $product->getName());
     if ($this->checkProductExist($product->getName()) === FALSE) {
         try {
             self::$conn->preparedInsert("termekek", array("nev", "kat_azon", "kisz_azon", "suly", "egysegar", "min_keszlet", "min_rend", "kim_azon", "akcio", "reszletek", "kep"), array($product->getName(), $product->getCategory(), $product->getPackage(), $product->getWeight(), $product->getPrice(), $product->getMinStock(), $product->getMinOrder(), $product->getHighlight(), $product->getDiscount(), $product->getDescription(), $product->getImg()));
             //die("Sql után!");
         } catch (Exception $e) {
             return new Exception("Nem sikerült elmenteni a terméket!");
         }
         //$stmt = $conn->preparedQuery("SELECT t_azon FROM termekek WHERE nev=?",array("$name"));
         return "Sikeres termék felvitel!";
     } else {
         return "Létezik már ilyen termék!";
     }
 }
Example #2
0
    private $discount;
    function __construct($price, $discount)
    {
        $this->price = $price;
        $this->discount = $discount;
    }
    function getPrice()
    {
        return $this->price;
    }
    function getDiscount()
    {
        return $this->discount;
    }
}
class ProductAdapter
{
    private $product;
    function __construct(Product $product)
    {
        $this->product = $product;
    }
    function getPrice()
    {
        return $this->product->getPrice() - $this->product->getDiscount();
    }
}
$product1 = new Product(100, 20);
echo 'Discounted price = ' . ($product1->getPrice() - $product1->getDiscount());
$product2 = new ProductAdapter($product1);
echo 'Discounted price = ' . $product2->getPrice();
Example #3
0
 /**
  * 
  * @return Discount
  */
 public function getProductDiscount()
 {
     return $this->product->getDiscount();
 }