<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
<script type="text/javascript" src="./joose.js"></script>
<title>Joose Point</title>
<script type="text/javascript">
Class("Punto", {
has: {
x: {is: "rw"},
y: {is: "rw"}
},
methods: {
clear: function () {
this.setX(0);
this.setY(0);
}
}
});
Class("Punto3D", {
isa: Punto,
has: {
z: {is: "rw"}
},
after: {
clear: function () {
this.setZ(0);
}
}
});
</script>
</head>
<body>
<script type="text/javascript">
var point = new Punto3D();
point.setX(10);
point.setY(30);
var y = point.getY();
point.z = 1;
console.log("Un punto: ");
console.log(point);
console.log("var y: " + y);
point.clear();
console.log("Coordenada z luego de clear: " + point.getZ());
var point2 = new Punto3D({ x: 10, y: 20});
console.log("Coordenada y de point2: " + point2.y);
</script>
</body>
</html>
La salida en la consola del navegador es algo como esto:
runpoint.html:41 Un punto:
runpoint.html:42 f {x: 10, y: 30, z: 1}
runpoint.html:43 var y: 30
runpoint.html:45 Coordenada z luego de clear: 0
runpoint.html:47 Coordenada y de point2: 20
No hay comentarios:
Publicar un comentario