It is not the purpose of the site to solve the question but rather to ask questions. But it seems you are new so I will answer your question. We can define this class in many ways, but I chose to make it as easy as possible. Follow the code:
<?php
class Modulo{
private $resto;
public function restoDivisao($matricula, $denominador) {
$this->resto = $matricula%$denominador;
}
public function imprimeResto() {
echo $this->resto;
}
}
?>
Here we define the class that has only one parameter, which is the rest of the division. It is a private parameter, that is, it can only be accessed by the class’s own methods. To use this class you can do it as follows:
$resto = new Modulo;
$resto->restoDivisao(9,4);
$resto->imprimeResto();
First we instantiate the class, creating an object and storing it in the $resto variable. Then we call métido restoDivisao()
, passing as parameters the number of the registration (any number) and the divisor. This method makes the calculation of the rest and stores it in the private attribute. Then we call the method imprimeResto()
that takes the attribute we set in the previous method and prints on the screen.
What is your question? What have you tried to do?
– Roberto de Campos