Guest User

Untitled

a guest
Dec 14th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. <DOCTYPE html>
  2. <html lang="es">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title></title>
  6. <! <link href="css/estilo.css" rel="stylesheet" type="text/css"/>
  7. </head>
  8. <body>
  9. <table>
  10. <tr>
  11. <th>Nombre:</th><th><input type="text" id="PB"></th>
  12. </tr>
  13. <tr>
  14. <th>Descripcion</th><th><input type="text" id="IVA"></th>
  15. </tr>
  16. <tr>
  17. <th>Precio:</th><th><input type="text" id="IT"></th>
  18. </tr>
  19. <tr>
  20. <th><input type="button" OnClick="" value="Calcula IVA"></th>
  21. <th><input type="button" OnClick="" value="Calcula Preu brut"></th>
  22. <th><input type="button" OnClick="iva_calculator" value="Calcula Total"></th>
  23. </tr>
  24. </table>
  25. </body>
  26. </html>
  27.  
  28. <html>
  29. <script>
  30.  
  31. function Cuenta(titular, cantidad){
  32. this.titular = titular;
  33. if (cantidad < 0) {
  34. this.cantidad = 0;
  35. } else {
  36. this.cantidad = cantidad;
  37. }
  38. }
  39.  
  40.  
  41. Cuenta.prototype.getTitular = function(){
  42. return this.titular;
  43. }
  44.  
  45.  
  46. Cuenta.prototype.setTitular = function(titular){
  47. this.titular = titular;
  48. }
  49.  
  50. Cuenta.prototype.getCantidad = function () {
  51. return this.cantidad;
  52. }
  53.  
  54. Cuenta.prototype.setCantidad=function(cantidad) {
  55. this.cantidad = cantidad;
  56. }
  57.  
  58. Cuenta.prototype.toString = function() {
  59. return "El titular " + this.titular + " tiene " + this.cantidad + " euros en la cuenta";
  60. }
  61.  
  62. Cuenta.prototype.ingresar = function (cantidad) {
  63. if(cantidad > 0){
  64. this.cantidad += cantidad;
  65. }
  66. }
  67.  
  68. Cuenta.prototype.retirar = function(cantidad) {
  69. if (this.cantidad - Math.abs(cantidad) < 0) {
  70. this.cantidad = 0;
  71. } else {
  72. this.cantidad -= cantidad;
  73. }
  74. }
  75.  
  76.  
  77. var cuenta_2 = new Cuenta("Fernando", 300);
  78. alert(cuenta_2.toString());
  79. cuenta_2.ingresar(400);
  80. cuenta_2.retirar(100);
  81. alert(cuenta_2.toString());
  82.  
  83.  
  84.  
  85. </script>
  86.  
  87. </html>
  88.  
  89. cuenta_2.setTitular("Soy el nuevo titular"); //Cambiará el titular del objeto
  90. cuenta_2.ingresar(900);
  91. cuenta_2.retirar(10);
  92. alert(cuenta_2.toString());
  93. alert(cuenta_2.getTitular()); //Leerá el titular actual del objeto
  94. alert(cuenta_2.getCantidad()); //Leerá la cantidad del objeto
Add Comment
Please, Sign In to add comment