Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Persona
- { public $nombre;
- public $identificacion;
- // public $edad;
- function __construct($nombre, $id)
- {
- $this->nombre = $nombre;
- $this->identificacion = $id;
- }
- public function Mostrar()
- {
- $res = "Nombre : $this->nombre - Identificación : $this->identificacion";
- return $res;
- }
- }
- class Estudiante extends Persona
- {
- public $nota1;
- public $nota2;
- public $nota3;
- function setNotas($n1,$n2,$n3)
- {
- $this->nota1 = $n1;
- $this->nota2 = $n2;
- $this->nota3 = $n3;
- }
- public function Mostrar()
- { $per = parent::Mostrar();
- $res = $per.'<br>';
- $res .= "Nota1 : $this->nota1 / Nota2 : $this->nota2 / Nota3 : $this->nota3";
- return $res;
- }
- }
- $est1 = new Estudiante("Carlos", '456');
- $est1->setNotas(3.2, 2.5, 2.2);
- echo $est1->Mostrar().'<br>';
- // var_dump($est1);
- /*
- $per1 = new Persona("Pedro", "123"); // creando un objeto
- $x = $per1->Mostrar();
- echo $x;
- */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement