Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>ciao</title>
  6. <script> class cane {
  7.  
  8. constructor(nome, colore) {
  9.  
  10. this.nome = nome;
  11.  
  12. this.colore = colore;
  13.  
  14. }
  15.  
  16. mostranomeecolore() {
  17.  
  18. document.write( "il cane si chiama: "+ this.nome +" ed è di colore " + this.colore+" ");
  19.  
  20. }}
  21. class goldenretriever extends cane {
  22. constructor(nome, colore, salvataggio) {
  23.  
  24. super(nome,colore);
  25.  
  26. this.salvataggio = salvataggio; }
  27.  
  28. mostraaddestramento() {
  29.  
  30. document.write(super.mostranomeecolore());}
  31. }
  32. cane1 = new goldenretriever("fido", "miele", "si");
  33.  
  34. cane2 = new goldenretriever("luna", "cioccolato", "no");
  35. </script>
  36. </head>
  37. <body>
  38.  
  39. <p onclick="alert(cane1.nome)">Come si chiama il cane?</p>
  40. <p onclick="alert(cane2.colore)">Che razza è il cane?</p>
  41. <p onclick="alert(cane2.salvataggio)">Può fare salvataggio?<p>
  42. <p onclick="cane2.mostraaddestramento()">mostra nome e addestramento</p>
  43. <p onclick="cane2.mostranomeecolore()">mostra nome e addestramento</p>
  44.  
  45.  
  46.  
  47.  
  48. </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement