In this fragment of object-oriented programming I must create a single class with a "building" indicator and the properties "name", "description", "address", "data inauguration", "architect" and "cost". Must have methods to consult and modify the mentioned properties, a method constructor of the class (that I intuit that it will be the creation of the function of the class) and, later, create another method that shows in a modal window all the properties. Finally I must create an instance of the previous class and call the method that shows the properties.
Later I added an HTML5 document with the following fragment to call the javascript program with a button.
This is the code I used:
function edificio() {
this.nombre = nombre;
this.descripcion = descripcion;
this.direccion = direccion;
this.inauguracion = inauguracion;
this.arquitecto = arquitecto;
this.coste = 0;
}
edificio.prototype.consultarnombre() {
return nombre;
}
edificio.prototype.nombrar(nombre) {
this.nombre = nombre;
}
edificio.prototype.consultardescripcion() {
return descripcion;
}
edificio.prototype.describir(descripcion) {
this.descripcion = descripcion;
}
edificio.prototype.consultardireccion() {
return direccion;
}
edificio.prototype.direccion(direccion) {
this.direccion = direccion;
}
edificio.prototype.consultarinauguracion() {
return inauguracion;
}
edificio.prototype.inaugurar(inauguracion) {
this.inauguracion = inauguracion;
}
edificio.prototype.consultararquitecto() {
return arquitecto;
}
edificio.prototype.arquitecto(arquitecto) {
this.arquitecto = arquitecto;
}
edificio.prototype.consultarcoste() {
return coste;
}
edificio.prototype.precio(coste) {
this.coste = coste;
}
edificio.prototype.muestra() {
alert(nombre + ". " + descripcion + ". " + direccion + ". Inaugurado el
"+inauguracion+".Creado por "+arquitecto+".Vale "+coste);
}
var miedificio = new edificio();
miedificio.nombrar("Salmon")
miedificio.muestra();
<p>POO
<form name="miform">
<input type="button" name="boton" value="Pulsa para empezar" onClick="javaScript: edificio()">
</form>
</p>
The problem is that the call to the modal window is not even executed. Neither comes out nor NaN, since at the moment I have not entered any data. How can I solve it?
Neither do I know how I could modify the properties with the methods, that is, enter the data.