Help with object creation

Asked

Viewed 28 times

0

How I put the method descontoINSS on that page?

<?php
include_once("Pessoa-class.php");
include_once("PessoaFisica-class.php");
include_once("Funcionario-class.php");
include_once("index.php");
$nome = $_POST['nome'];
$sexo = $_POST['sexo'];
$CPF = $_POST['cpf'];
$salario = $_POST['salario'];

$Funcionario = new Funcionario();
$Funcionario->setNome($nome);
$Funcionario->setSexo($sexo);
$Funcionario->setSalario($salario);
$Funcionario->descontoINSS($x);
echo "O valor de desconto do INSS é R$ $x";
?>

the method is in this class?

<?php
    class Funcionario extends Pessoa {
        private $salario;
        public function getSalario(){
            return $this->salario;
        }
        public function setSalario($salario){
            if ($salario<0)
                echo "ERRO: Salário não pode ser negativo";
            else
                $this->salario = $salario;
        }
        public function descontoINSS($x){
            return $x = 0.11*$this->salario;
        }
    }
?>
  • Declare a variable that will receive the return of the method descontoINSS ... $x = $Funcionario->descontoINSS($salario);

  • 2

    I’m voting to close because apparently the user has been removed.

  • The author of the question has just come and gone?

  • @Good victorstafusa had the name Carla, asked the question, edited at the same time I was adjusting the formatting, and then just disappeared.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.