<?php
class Calculadora {
public function __construct($num1, $num2){
$this-> num1 = $num1;
$this-> num2 = $num2;
}
# Definindo função soma
public function somar(){
$resultado=$this-> num1+$this-> num2;
return $resultado;
}
# Definindo função multiplica
function multiplicar(){
$resultado=$this-> num1*$this-> num2;
return $resultado;
}
}
$obj = new Calculadora(5,8);
echo $obj->multiplicar(); // Deveria exibir: 40
PD9waHAKCiAgICBjbGFzcyBDYWxjdWxhZG9yYSB7CgogICAgICAgIHB1YmxpYyBmdW5jdGlvbiBfX2NvbnN0cnVjdCgkbnVtMSwgJG51bTIpewogICAgICAgICAgICAkdGhpcy0+IG51bTEgPSAkbnVtMTsKICAgICAgICAgICAgJHRoaXMtPiBudW0yID0gJG51bTI7CiAgICAgICAgfQogICAgCiAgICAgICAgIyBEZWZpbmluZG8gZnVuw6fDo28gc29tYQogICAgICAgIHB1YmxpYyBmdW5jdGlvbiBzb21hcigpewogICAgICAgICAgICAkcmVzdWx0YWRvPSR0aGlzLT4gbnVtMSskdGhpcy0+IG51bTI7CiAgICAgICAgICAgIHJldHVybiAkcmVzdWx0YWRvOwogICAgICAgIH0KICAgIAogICAgICAgICMgRGVmaW5pbmRvIGZ1bsOnw6NvIG11bHRpcGxpY2EKICAgICAgICBmdW5jdGlvbiBtdWx0aXBsaWNhcigpewogICAgICAgICAgICAkcmVzdWx0YWRvPSR0aGlzLT4gbnVtMSokdGhpcy0+IG51bTI7CiAgICAgICAgICAgIHJldHVybiAkcmVzdWx0YWRvOwogICAgICAgIH0KICAgIH0KICAgIAogICAgCiAgICAgICAgJG9iaiA9IG5ldyBDYWxjdWxhZG9yYSg1LDgpOwogICAgICAgIGVjaG8gJG9iai0+bXVsdGlwbGljYXIoKTsgICAvLyBEZXZlcmlhIGV4aWJpcjogNDAKCg==