It is not the purpose of the site to resolve the issue, but to ask questions. But apparently you're new, so I'll answer your question. We can define this class in many ways, but I chose to do it as easily as possible. Here is 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 the following:
$resto = new Modulo;
$resto->restoDivisao(9,4);
$resto->imprimeResto();
First we instantiate the class, creating an object and saving it in the $ rema variable. Then we call métido restoDivisao()
, passing as parameters the number of the enrollment (any number) and the divisor. This method does the remainder calculation and saves it to the private attribute. Then we call the imprimeResto()
method that takes the attribute we set in the previous method and prints on the screen.