Page 347 - CITS - CSA - TP (Volume 1) - Hindi
P. 347
कंप्यूटर सॉफ्टवेयर एप्लीकेशन- CITS
{
parent::__construct($name);
$this->radius = $radius;
}
// Implementing abstract method
public function calculateArea()
{
return pi() * pow($this->radius, 2);
}
}
// Concrete subclass of Shape
class Square extends Shape
{
private $side;
public function __construct($name, $side)
{
parent::__construct($name);
$this->side = $side;
}
// Implementing abstract method
public function calculateArea()
{
return pow($this->side, 2);
}
}
// Creating instances of concrete subclasses
$circle = new Circle(“Circle”, 5);
$square = new Square(“Square”, 4);
// Calling methods on instances
echo”Area of circle is :”.$circle->calculateArea(); // Output: 78.539816339745
echo “<br/>”;
echo”Area of square is :”.$square->calculateArea(); // Output: 16
?>
</body>
</html>
3 ो ाम को C:\Apache24\htdocs म .php ए ट शन वाले फ़ो र म सेव कर
4 Apache सिव स को िवंडोज़ सिव स से रन कर
5 ाउज़र ओपन कर और िन एड ेस टाइप कर
http://localhost/foldername/
6 रन करने के िलए php फ़ाइल पर क कर और आउटपुट वेरीफाई कर
331
CITS : IT & ITES - कं ूटर सॉ वेयर ए ीके शन - अ ास 60

