Diferència entre revisions de la pàgina «Solucio Profes»

De wikiserver
Dreceres ràpides: navegació, cerca
Línia 43: Línia 43:
  
 
}
 
}
//apunta al constructor y a la clase persona
+
//Hereda de Persona
 
Profesor.prototype=new Persona();
 
Profesor.prototype=new Persona();
 +
//Apunta al constructor de Profesor
 
Profesor.prototype.constructor=Profesor;
 
Profesor.prototype.constructor=Profesor;
  
Línia 205: Línia 206:
  
  
var profe1 = new Persona("julio","noguera",12);
+
var person= new Persona("julio","noguera",12);
 
var pr=new Profesor("sergio", "rodriguez",16);
 
var pr=new Profesor("sergio", "rodriguez",16);
 
var listaProfe= new ListaP();
 
var listaProfe= new ListaP();
  
listaProfe.insertarProfe(profe1);
+
listaProfe.insertarProfe(person);
 
listaProfe.insertarProfe(pr);
 
listaProfe.insertarProfe(pr);
 
listaProfe.insertarProfe(new PFijo("pepe","ramirez",12,20038338));
 
listaProfe.insertarProfe(new PFijo("pepe","ramirez",12,20038338));
 
listaProfe.insertarProfe(new PInterino("juanra","tamiz",23,new Date().getDate()));
 
listaProfe.insertarProfe(new PInterino("juanra","tamiz",23,new Date().getDate()));
  
//var perso=listaProfe.obtenerProfe();
+
//var perso=listaProfe.obtenerProfe();   //obtendria últim Profe
  
 
listaProfe.mostrarProfes();
 
listaProfe.mostrarProfes();
 
</source>
 
</source>

Revisió del 12:49, 20 nov 2014

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);

}
//Hereda de Persona
Profesor.prototype=new Persona();
//Apunta al constructor de Profesor
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;
}

//Hereda de Persona
PFijo.prototype=new Persona();
// corrige el puntero del constructor porque apunta a 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;

}

//Hereda de Persona
PInterino.prototype=new Persona();
// corrige el puntero del constructor porque apunta a 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 person= new Persona("julio","noguera",12);
var pr=new Profesor("sergio", "rodriguez",16);
var listaProfe= new ListaP();

listaProfe.insertarProfe(person);
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();   //obtendria últim Profe

listaProfe.mostrarProfes();