Solucio Profes

De wikiserver
La revisió el 12:42, 20 nov 2014 per Jnoguera (Discussió | contribucions) (Es crea la pàgina amb «function Persona(nombre,apellido,edad){ this.nombre=nombre; this.apellido=apellido; this.edad=edad; } Persona.prototype.getNombre=function(){ return nombre; } Perso…».)
(dif) ← Versió més antiga | Versió actual (dif) | Versió més nova → (dif)
Dreceres ràpides: navegació, cerca

function Persona(nombre,apellido,edad){ this.nombre=nombre; this.apellido=apellido; this.edad=edad; }

Persona.prototype.getNombre=function(){ return nombre; }

Persona.prototype.setNombre=function(name){ this.nombre= name; }

Persona.prototype.getApellido=function(){ return apellido; }

Persona.prototype.setApellido=function(surname){ this.apellido= surname; }

Persona.prototype.getedad=function(){ return edad; }

Persona.prototype.setedad=function(age){ this.edad= age; }


Persona.prototype.mostrarP=function(){ document.write(this.nombre); document.write(this.apellido);

}

function Profesor(nombre, apellido, edad){

Persona.call(this,nombre, apellido, edad);

} //apunta al constructor y a la clase persona Profesor.prototype=new Persona(); Profesor.prototype.constructor=Profesor;


Profesor.prototype.getNombre=function(){ return nombre; }

Profesor.prototype.setNombre=function(name){ this.nombre= name; }

Profesor.prototype.getApellido=function(){ return apellido; }

Profesor.prototype.setApellido=function(surname){ this.apellido= surname; }

Profesor.prototype.getedad=function(){ return edad; }

Profesor.prototype.setedad=function(age){ this.edad= age; }

Profesor.prototype.mostrarP=function(){ document.write(this.nombre); document.write(this.apellido);

}


function PFijo(nombre, apellido, edad,id){

Persona.call(this,nombre, apellido, edad);

this.id=id; }

//apunta al constructor y a la clase persona PFijo.prototype=new Persona(); PFijo.prototype.constructor=PFijo;


PFijo.prototype.getNombre=function(){ return nombre; }

PFijo.prototype.setNombre=function(name){ this.nombre= name; }

PFijo.prototype.getApellido=function(){ return apellido; }

PFijo.prototype.setApellido=function(surname){ this.apellido= surname; }

PFijo.prototype.getedad=function(){ return edad; }

PFijo.prototype.setedad=function(age){ this.edad= age; } PFijo.prototype.getId=function(){ return edad; }

PFijo.prototype.setId=function(identificacion){ this.id= identificacion; }

PFijo.prototype.mostrarP=function(){ document.write(this.nombre); document.write(this.apellido);

}

function PInterino(nombre, apellido, edad, fecha){

Persona.call(this,nombre, apellido, edad);

this.fecha=fecha; var that=this;

}

//apunta al constructor y a la clase persona PInterino.prototype=new Persona(); PInterino.prototype.constructor=PInterino;


PInterino.prototype.getNombre=function(){ return nombre; }

PInterino.prototype.setNombre=function(name){ this.nombre= name; }

PInterino.prototype.getApellido=function(){ return apellido; }

PInterino.prototype.setApellido=function(surname){ this.apellido= surname; }

PInterino.prototype.getedad=function(){ return edad; }

PInterino.prototype.setedad=function(age){ this.edad= age; }

PInterino.prototype.setFecha=function(data){ this.fecha=data; }

PInterino.prototype.getFecha=function(){ return fecha; }

PInterino.prototype.mostrarP=function(){ var that=this; document.write(this.nombre); document.write(this.apellido); document.write(this.fecha);

}

function ListaP(){

var lista=[]

this.insertarProfe=function(Profesor){ return lista.push(Profesor); }

this.obtenerProfe=function(){ return lista.pop(); }

this.mostrarProfes=function(){ for (var i = lista.length - 1; i >= 0; i--) { var valor= lista.pop(); valor.mostrarP(); };

} }


var profe1 = new Persona("julio","noguera",12); var pr=new Profesor("sergio", "rodriguez",16); var listaProfe= new ListaP();

listaProfe.insertarProfe(profe1); listaProfe.insertarProfe(pr); listaProfe.insertarProfe(new PFijo("pepe","ramirez",12,20038338)); listaProfe.insertarProfe(new PInterino("juanra","tamiz",23,new Date().getDate()));

//var perso=listaProfe.obtenerProfe();

listaProfe.mostrarProfes();