0
I am with a small doubt, I was making a web application in PHP that simulated a student, displaying his information as his name, enrollment, note 1, note 2 and the average of these notes, but when I will put to display the average appears the error described in the title of this post, thanks if you can help (the error happens on line 24 of the index.php code, but I will leave the code of the other classes)
index php.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Teste</title>
</head>
<body>
<?php
require_once 'Aluno.php';
$aluno = new Aluno();
$aluno->nome = 'Paulo';
$aluno->matricula = '20210827';
$aluno->nota1 = 9;
$aluno->nota2 = 8;
echo 'Nome: '.$aluno->nome;
echo '<br>Matricula: '.$aluno->matricula;
echo '<br>Nota 1: '.$aluno->nota1;
echo '<br>Nota 2: '.$aluno->nota2;
echo '<br><br>';
echo 'Média: '.$aluno.getMedia();
?>
</body>
</html>
Pupil.php
<?php
require 'Calculadora.php';
class Aluno {
public $nome;
public $matricula;
public $nota1; // valor padrão = 0
public $nota2; // valor padrão = 0
function getMedia() {
$calc1 = new Calculadora($this->valor1, $this->valor2);
$calc1->valor1 = $this->nota1;
$calc1->valor1 = $this->nota2;
$calc1->getDivisao();
}
}
Calculator.php
<?php
class Calculadora {
public $valor1;
public $valor2;
function __construct($valor1, $valor2) {
$this->valor1 = $valor1;
$this->valor2 = $valor2;
}
function getValor1() {
return $this->valor1;
}
function getValor2() {
return $this->valor2;
}
function getSoma() {
return $this->valor1 + $this->valor2;
}
function getSubtracao() {
return $this->valor1 - $this->valor2;
}
function getMultiplicacao() {
return $this->valor1 * $this->valor2;
}
function getDivisao() {
return $this->valor1 / $this->valor2;
}
}