Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <DOCTYPE html>
- <html lang="es">
- <head>
- <meta charset="utf-8" />
- <title></title>
- <! <link href="css/estilo.css" rel="stylesheet" type="text/css"/>
- </head>
- <body>
- <table>
- <tr>
- <th>Nombre:</th><th><input type="text" id="PB"></th>
- </tr>
- <tr>
- <th>Descripcion</th><th><input type="text" id="IVA"></th>
- </tr>
- <tr>
- <th>Precio:</th><th><input type="text" id="IT"></th>
- </tr>
- <tr>
- <th><input type="button" OnClick="" value="Calcula IVA"></th>
- <th><input type="button" OnClick="" value="Calcula Preu brut"></th>
- <th><input type="button" OnClick="iva_calculator" value="Calcula Total"></th>
- </tr>
- </table>
- </body>
- </html>
- <html>
- <script>
- function Cuenta(titular, cantidad){
- this.titular = titular;
- if (cantidad < 0) {
- this.cantidad = 0;
- } else {
- this.cantidad = cantidad;
- }
- }
- Cuenta.prototype.getTitular = function(){
- return this.titular;
- }
- Cuenta.prototype.setTitular = function(titular){
- this.titular = titular;
- }
- Cuenta.prototype.getCantidad = function () {
- return this.cantidad;
- }
- Cuenta.prototype.setCantidad=function(cantidad) {
- this.cantidad = cantidad;
- }
- Cuenta.prototype.toString = function() {
- return "El titular " + this.titular + " tiene " + this.cantidad + " euros en la cuenta";
- }
- Cuenta.prototype.ingresar = function (cantidad) {
- if(cantidad > 0){
- this.cantidad += cantidad;
- }
- }
- Cuenta.prototype.retirar = function(cantidad) {
- if (this.cantidad - Math.abs(cantidad) < 0) {
- this.cantidad = 0;
- } else {
- this.cantidad -= cantidad;
- }
- }
- var cuenta_2 = new Cuenta("Fernando", 300);
- alert(cuenta_2.toString());
- cuenta_2.ingresar(400);
- cuenta_2.retirar(100);
- alert(cuenta_2.toString());
- </script>
- </html>
- cuenta_2.setTitular("Soy el nuevo titular"); //Cambiará el titular del objeto
- cuenta_2.ingresar(900);
- cuenta_2.retirar(10);
- alert(cuenta_2.toString());
- alert(cuenta_2.getTitular()); //Leerá el titular actual del objeto
- alert(cuenta_2.getCantidad()); //Leerá la cantidad del objeto
Add Comment
Please, Sign In to add comment