Final answer:
To create the PHP class 'Product' with the given properties and methods, and perform the instructions provided.
Step-by-step explanation:
To create the PHP class 'Product' with the given properties and methods, you can use the following code:
<?php
class Product {
private $name;
private $price;
private $quantity;
public function __construct($name, $price, $quantity) {
$this->name = $name;
$this->price = $price;
$this->quantity = $quantity;
}
public function getName() {
return $this->name;
}
public function getPrice() {
return $this->price;
}
public function getQuantity() {
return $this->quantity;
}
public function setName($name) {
$this->name = $name;
}
public function setPrice($price) {
$this->price = $price;
}
public function setQuantity($quantity) {
$this->quantity = $quantity;
}
public function getTotalPrice() {
return $this->price * $this->quantity;
}
}
To perform the given instructions:
<?php
$product = new Product('thigh snack', 7.50, 3);
echo $product->getName();
echo $product->getPrice();
echo $product->getQuantity();
echo $product->getTotalPrice();
$product->setName('conch snack');
$product->setPrice(10.95);
$product->setQuantity(5);
echo $product->getName();
echo $product->getPrice();
echo $product->getQuantity();
echo $product->getTotalPrice();